Farah work¶

We import the data and clean it¶

In [2]:
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
from scipy import stats
from sklearn.linear_model import LinearRegression
from sklearn.cluster import KMeans
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler

In total we have 362 rows(participant) but not all of them answer to all the Questions¶

In [3]:
# Specify the path to your Excel file
excel_file_path = 'C:/Users/samir/Farah_new1.xlsx'

df = pd.read_excel(excel_file_path)
num_rows = len(df)
print("Number of rows:", num_rows)


df = pd.read_excel(excel_file_path).dropna()

df.head(10)
Number of rows: 362
Out[3]:
طابع زمني result your gender Your age your years of experience your monthly income Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception? women cant use a copper IUD if she one of the following is consider as advantage of hormonal IUD An IUD can be inserted ... IUD Do not cause cancer. IUD Do not move to the heart or brain IUD cause discomfort or pain for the woman or the man during sex. IUD Substantially reduce the risk of ectopic pregnancy. A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice? WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ? A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ? A woman has acne while using an IUD. What is your advice? For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT? what is your information source/s about IUD ?
1 2024-01-28 19:06:50.527 21 Female 25.0 1.0 0.0 Reduction of heavy menstrual bleeding all of above women can have irregular bleeding, lighter per... at Ovulation days (14-16). ... Agree Agree Agree Agree Consult a gynecologist to rule out pelvic infl... all of above Take norethisterone 5mg/12 hrs consider locally available remedies Consult a gynecologist My university studies
3 2024-01-28 20:13:21.480 18 Female 24.0 22.0 222.0 Treatment of endometrial cancer all of above all of above at any time . ... Disagree Agree I do not know Disagree Reassure her that many women using IUDs experi... she should Regularly check her blood strength ... Reassure her that many women eventually stop h... consider locally available remedies Use a hot water bottle or a heating pad set on... My university studies
8 2024-02-01 18:44:29.684 18 Female 33.0 9.0 500.0 Prophylaxis of pelvic inflammatory disease have an allergy to copper it protect against sexually transmitted infec... during the period or at the day after your per... ... Agree Agree Agree Disagree Use NSAIDs to treat fever and pain. she should use hormonal iud insted If it keep ... assess for pregnancy or other underlying cond... suggest switching to COCs. Many women’s acne i... Use a hot water bottle or a heating pad set on... My university studies
9 2024-02-01 18:45:09.874 24 Female 35.0 3.0 500.0 Reduction of heavy menstrual bleeding all of above all of above during the period or at the day after your per... ... Agree Agree Disagree Agree Consult a gynecologist to rule out pelvic infl... she should use hormonal iud insted If it keep ... Take norethisterone 5mg/12 hrs all of above a and b Self experience
10 2024-02-01 18:48:20.221 23 Female 28.0 7.0 500.0 Reduction of heavy menstrual bleeding all of above all of above during the period or at the day after your per... ... Agree Agree Agree Disagree Consult a gynecologist to rule out pelvic infl... all of above Take norethisterone 5mg/12 hrs all of above a and b My university studies, Research
11 2024-02-01 18:53:13.563 24 Female 43.0 20.0 1000.0 Reduction of heavy menstrual bleeding all of above women can have irregular bleeding, lighter per... during the period or at the day after your per... ... Agree Agree Disagree Disagree Consult a gynecologist to rule out pelvic infl... she should use hormonal iud insted If it keep ... assess for pregnancy or other underlying cond... all of above Consult a gynecologist Self experience
12 2024-02-01 19:24:52.428 21 Female 26.0 2.0 250.0 Normalizing erratic menstrual cycles all of above women who have recent pelvic infection can use it during the period or at the day after your per... ... Disagree Agree Agree Agree Consult a gynecologist to rule out pelvic infl... all of above Reassure her that many women eventually stop h... suggest switching to COCs. Many women’s acne i... a and b My university studies, Self experience
13 2024-02-01 22:02:04.063 23 Female 29.0 2.0 300.0 Normalizing erratic menstrual cycles all of above it protect against sexually transmitted infec... at Ovulation days (14-16). ... Agree Disagree Disagree Agree Consult a gynecologist to rule out pelvic infl... all of above Take norethisterone 5mg/12 hrs all of above a and b My university studies
14 2024-02-02 12:06:51.981 23 Female 28.0 3.0 300.0 Reduction of heavy menstrual bleeding all of above women who have recent pelvic infection can use it during the period or at the day after your per... ... Agree Agree Disagree Agree Consult a gynecologist to rule out pelvic infl... all of above Reassure her that many women eventually stop h... suggest switching to COCs. Many women’s acne i... a and b My university studies, Self experience
15 2024-02-02 12:12:08.455 22 Female 34.0 10.0 600.0 Treatment of endometrial cancer all of above all of above at any time . ... Agree Agree Disagree I do not know Consult a gynecologist to rule out pelvic infl... all of above assess for pregnancy or other underlying cond... all of above Take an over-the-counter pain medicine, such a... Self experience

10 rows × 28 columns

In [4]:
df.replace(r'^\s*$', None, regex=True, inplace=True)

# Fill None values with NaN
df.fillna(pd.NA, inplace=True)

# Drop rows where values in a specific column are more than 21
df = df[df['result'] <= 21]
In [5]:
#Count the number of missing values in each column
missing_counts = df.isna().sum()

# Count the number of "Not Measured" values in each column
not_measured_counts = (df == "Not Measured").sum()

# Sum the missing counts and "Not Measured" counts across all columns
total_missing_count = missing_counts.sum()
total_not_measured_count = not_measured_counts.sum()

# Display the results
print("Total number of missing values in the dataset:", total_missing_count)
print("Total number of 'Not Measured' values in the dataset:", total_not_measured_count)

num_rows = len(df)
print("Number of rows:", num_rows)
Total number of missing values in the dataset: 0
Total number of 'Not Measured' values in the dataset: 0
Number of rows: 315

after cleaning and removing the empty rows the number dropped to 315 rows(participant) ,We are going to work with these rows(participant)¶

Then next we view the columns and their unique values¶

In [6]:
print(df.columns)
Index(['طابع زمني', 'result', 'your  gender', 'Your age ',
       'your years of experience', 'your monthly income ',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?',
       'women cant use a copper IUD if she  ',
       'one of the following is consider as advantage of hormonal IUD ',
       'An IUD can be inserted  ',
       'both hormonal and copper IUD are safe to use while breastfeeding.',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD',
       'IUD Can be used by women of any age, including adolescents.',
       'IUD Can not be used by women who have not had   children ',
       'IUD increase the risk of contracting STIs, including HIV\n',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed',
       'IUD make women infertile.', 'IUD  cause birth defects.',
       'IUD Do not cause cancer.', 'IUD Do not move to the heart or brain',
       'IUD cause discomfort or pain for the woman or the man during sex.',
       'IUD Substantially reduce the risk of ectopic pregnancy.',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  ',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?',
       'A woman has acne while using an IUD. What is your advice?',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?',
       'what is your information source/s about IUD ?'],
      dtype='object')
In [7]:
columns_to_check = ['result', 'your  gender', 'Your age ',
       'your years of experience', 'your monthly income ',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?',
       'women cant use a copper IUD if she  ',
       'one of the following is consider as advantage of hormonal IUD ',
       'An IUD can be inserted  ',
       'both hormonal and copper IUD are safe to use while breastfeeding.',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD',
       'IUD Can be used by women of any age, including adolescents.',
       'IUD Can not be used by women who have not had   children ',
       'IUD increase the risk of contracting STIs, including HIV\n',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed',
       'IUD make women infertile.', 'IUD  cause birth defects.',
       'IUD Do not cause cancer.', 'IUD Do not move to the heart or brain',
       'IUD cause discomfort or pain for the woman or the man during sex.',
       'IUD Substantially reduce the risk of ectopic pregnancy.',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  ',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?',
       'A woman has acne while using an IUD. What is your advice?',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?',
       'what is your information source/s about IUD ?']

for column in columns_to_check:
    unique_values = df[column].unique()
    print(f"Unique values for '{column}': {unique_values}")
Unique values for 'result': [21 18 15 17 19 20  8 16 13 12 14  9 11  7  3 10  2  6  5  4]
Unique values for 'your  gender': ['Female' 'Male']
Unique values for 'Your age ': [25. 24. 33. 26. 27. 30. 23. 34. 31. 42. 28. 29. 53. 43. 41. 35. 40. 45.
 32. 44. 37. 36. 38. 39. 55. 22. 60. 51. 54. 46. 49. 47. 56. 63. 50.]
Unique values for 'your years of experience': [ 1.  22.   9.   2.   3.   8.  28.  11.5  4.   5.  20.  12.  10.   0.6
  6.  45.   7.  19.  18.  16.  11.  17.  14.  15.  13.  24.  23.  30.
 40.  27.  26.  43.  25.  21.  31. ]
Unique values for 'your monthly income ': [0.00e+00 2.22e+02 5.00e+02 2.50e+02 4.50e+02 2.60e+02 2.00e+00 1.00e+03
 6.00e+02 4.00e+02 7.00e+02 4.70e+02 3.00e+02 3.90e+02 5.60e+02 5.80e+02
 6.10e+02 4.30e+02 3.80e+02 4.20e+02 3.40e+02 4.10e+02 4.40e+02 5.40e+02
 7.90e+02 5.30e+02 6.40e+02 3.70e+02 7.40e+02 3.60e+02 5.20e+02 7.25e+02
 4.90e+02 6.34e+02 6.20e+02 4.58e+02 5.70e+02 4.49e+02 7.56e+02 5.98e+02
 6.24e+02 3.42e+02 3.10e+02 2.90e+02 3.20e+02 3.45e+02 4.35e+02 4.67e+02
 4.83e+02 3.50e+02 3.85e+02 3.78e+02 4.60e+02 2.80e+02 3.30e+02 5.10e+02
 4.45e+02 3.35e+02 4.15e+02 4.25e+02 1.30e+03 4.80e+02 5.50e+02 5.50e+03
 3.75e+02 3.65e+02 3.86e+02 4.56e+02 1.70e+01 1.80e+01 3.25e+02 4.65e+02
 4.78e+02 3.95e+02 3.15e+02 2.75e+02 3.64e+02 4.55e+02 2.95e+02 4.36e+02
 3.72e+02 3.55e+02]
Unique values for 'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?': ['Reduction of heavy menstrual bleeding' 'Treatment of endometrial cancer'
 'Prophylaxis of pelvic inflammatory disease'
 'Normalizing erratic menstrual cycles']
Unique values for 'women cant use a copper IUD if she  ': ['all of above' 'have an allergy to copper'
 'have Wilson’s disease, which causes the body hold too much copper.'
 'have Severe anemia']
Unique values for 'one of the following is consider as advantage of hormonal IUD ': ['women can have irregular bleeding, lighter periods, or no period at all.'
 'all of above' 'it protect  against sexually transmitted infections'
 'women who have recent pelvic infection can use it']
Unique values for 'An IUD can be inserted  ': ['at Ovulation days (14-16).' 'at any time .'
 'during the period or at the day after your period finish']
Unique values for 'both hormonal and copper IUD are safe to use while breastfeeding.': [0. 1.]
Unique values for 'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD': [1. 0.]
Unique values for 'IUD Can be used by women of any age, including adolescents.': ['Agree' 'I dont know' 'Disagree']
Unique values for 'IUD Can not be used by women who have not had   children ': ['Agree' 'Disagree' 'I dont know']
Unique values for 'IUD increase the risk of contracting STIs, including HIV
': ['Agree' 'I dont know' 'Disagree']
Unique values for 'IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed': ['Disagree' 'Agree' 'I dont know']
Unique values for 'IUD make women infertile.': ['Disagree' 'I dont know' 'Agree']
Unique values for 'IUD  cause birth defects.': ['Disagree' 'I do not know' 'Agree']
Unique values for 'IUD Do not cause cancer.': ['Agree' 'Disagree' 'I do not know']
Unique values for 'IUD Do not move to the heart or brain': ['Agree' 'Disagree' 'I do not know']
Unique values for 'IUD cause discomfort or pain for the woman or the man during sex.': ['Agree' 'I do not know' 'Disagree']
Unique values for 'IUD Substantially reduce the risk of ectopic pregnancy.': ['Agree' 'Disagree' 'I do not know']
Unique values for 'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?': ['Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.'
 'Reassure her that many women using IUDs experience this symptoms'
 'Use NSAIDs to treat fever and pain.']
Unique values for 'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  ': ['all of above'
 'she should Regularly check her blood strength and ferretin levels.'
 'she should use hormonal iud insted If it keep going in this manner for long period'
 'she should take iron supplement to avoid anemia']
Unique values for 'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?': ['Take norethisterone 5mg/12 hrs'
 'Reassure her that many women eventually stop having monthly bleeding when using the hormonal IUD, and this is not harmful. It is not necessary to experience monthly blood loss.'
 'assess for pregnancy or other underlying  condition']
Unique values for 'A woman has acne while using an IUD. What is your advice?': ['consider locally available remedies'
 'suggest switching to COCs. Many women’s acne improves with COCs use'
 'all of above']
Unique values for 'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?': ['Consult a gynecologist'
 'Use a hot water bottle or a heating pad set on low on your belly for pain.'
 'a and b'
 'Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen']
Unique values for 'what is your information source/s about IUD ?': ['My university studies' 'My university studies, Self experience'
 'Self experience' 'Self experience, Research' 'Research'
 'My university studies, Self experience, Research'
 'My university studies, Research']

To work with the data we have to change it to a boolean form (True or False) beacease the Questions has answer (Correct Value)¶

In [8]:
dc_df = pd.get_dummies(df , columns = [ 'your  gender',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?',
       'women cant use a copper IUD if she  ',
       'one of the following is consider as advantage of hormonal IUD ',
       'An IUD can be inserted  ',
       'both hormonal and copper IUD are safe to use while breastfeeding.',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD',
       'IUD Can be used by women of any age, including adolescents.',
       'IUD Can not be used by women who have not had   children ',
       'IUD increase the risk of contracting STIs, including HIV\n',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed',
       'IUD make women infertile.', 'IUD  cause birth defects.',
       'IUD Do not cause cancer.', 'IUD Do not move to the heart or brain',
       'IUD cause discomfort or pain for the woman or the man during sex.',
       'IUD Substantially reduce the risk of ectopic pregnancy.',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  ',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?',
       'A woman has acne while using an IUD. What is your advice?',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?',
       'what is your information source/s about IUD ?'])
dc_df.head(10)
Out[8]:
طابع زمني result Your age your years of experience your monthly income your gender_Female your gender_Male Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Normalizing erratic menstrual cycles Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Prophylaxis of pelvic inflammatory disease Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding ... For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Use a hot water bottle or a heating pad set on low on your belly for pain. For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b what is your information source/s about IUD ?_My university studies what is your information source/s about IUD ?_My university studies, Research what is your information source/s about IUD ?_My university studies, Self experience what is your information source/s about IUD ?_My university studies, Self experience, Research what is your information source/s about IUD ?_Research what is your information source/s about IUD ?_Self experience what is your information source/s about IUD ?_Self experience, Research
1 2024-01-28 19:06:50.527 21 25.0 1.0 0.0 True False False False True ... False False False True False False False False False False
3 2024-01-28 20:13:21.480 18 24.0 22.0 222.0 True False False False False ... False True False True False False False False False False
8 2024-02-01 18:44:29.684 18 33.0 9.0 500.0 True False False True False ... False True False True False False False False False False
12 2024-02-01 19:24:52.428 21 26.0 2.0 250.0 True False True False False ... False False True False False True False False False False
18 2024-02-02 12:45:05.293 15 27.0 3.0 450.0 True False False True False ... False False False False False False False False True False
22 2024-02-02 13:05:15.950 17 30.0 8.0 250.0 True False False False False ... False False True False False False False False True False
23 2024-02-02 13:16:59.072 21 30.0 2.0 0.0 True False False False True ... False False False False False False False False False True
25 2024-02-02 13:46:35.816 19 24.0 1.0 260.0 True False True False False ... False False True False False False False True False False
26 2024-02-02 13:47:58.041 18 23.0 2.0 250.0 True False False False True ... True False False False False False False False True False
31 2024-02-02 14:23:44.134 20 27.0 28.0 2.0 True False False False True ... False False True False False False False False True False

10 rows × 80 columns

In [9]:
dc_df.dtypes
Out[9]:
طابع زمني                                                                                         datetime64[ns]
result                                                                                                     int64
Your age                                                                                                 float64
your years of experience                                                                                 float64
your monthly income                                                                                      float64
                                                                                                       ...      
what is your information source/s about IUD ?_My university studies, Self experience                        bool
what is your information source/s about IUD ?_My university studies, Self experience, Research              bool
what is your information source/s about IUD ?_Research                                                      bool
what is your information source/s about IUD ?_Self experience                                               bool
what is your information source/s about IUD ?_Self experience, Research                                     bool
Length: 80, dtype: object
In [10]:
# Assuming your DataFrame is named df_new and you want to save it to a file named 'new_data.xlsx'
#dc_df.to_excel('newFarah_data1.xlsx', index=False)

small describtion about the Age and Years of Experience¶

In [11]:
dc_df.describe()
Out[11]:
طابع زمني result Your age your years of experience your monthly income
count 315 315.000000 315.000000 315.000000 315.000000
mean 2024-02-26 13:56:29.057666560 8.320635 33.450794 10.454286 416.380952
min 2024-01-28 19:06:50.527000 2.000000 22.000000 0.600000 0.000000
25% 2024-02-14 16:44:28.186500096 6.000000 28.000000 5.000000 335.000000
50% 2024-03-02 17:31:39.100999936 8.000000 31.000000 8.000000 380.000000
75% 2024-03-11 17:44:27.974000128 10.000000 38.000000 14.000000 430.000000
max 2024-03-11 23:18:07.448000 21.000000 63.000000 45.000000 5500.000000
std NaN 3.518204 7.689431 7.372829 319.479973
In [12]:
# Iterate over each column and plot a pie chart
for column in df.columns:
    try:
        plt.figure()
        counts = df[column].value_counts()
        plt.pie(counts, labels=counts.index, autopct='%1.1f%%', startangle=140)
        plt.title(f'Proportion of Values for {column}')
        plt.axis('equal')
        plt.show()
    except Exception as e:
        print(f"Error plotting pie chart for column '{column}': {e}")
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [13]:
# Iterate over each column and plot a histogram
for column in df.columns:
    try:
        plt.figure()
        plt.hist(df[column], bins=5)
        plt.xlabel(column)
        plt.ylabel('Frequency')
        plt.title(f'Histogram of {column}')
        plt.show()
    except Exception as e:
        print(f"Error plotting histogram for column '{column}': {e}")
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [14]:
# Iterate over each column and plot a box plot
for column in df.columns:
    plt.figure()
    sns.boxplot(data=df[column])
    plt.title(f'Box Plot of {column}')
    plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
In [15]:
# Drop non-numeric columns
numeric_df = df.select_dtypes(include=[np.number])

# Compute correlation matrix
correlation_matrix = numeric_df.corr()
print(correlation_matrix)
                                                      result  Your age   \
result                                              1.000000  -0.096594   
Your age                                           -0.096594   1.000000   
your years of experience                           -0.037580   0.849318   
your monthly income                                 0.030953   0.276482   
both hormonal and copper IUD are safe to use wh...  0.211815   0.094385   
We must advise the patient to take iron-contain...  0.286821  -0.063612   

                                                    your years of experience  \
result                                                             -0.037580   
Your age                                                            0.849318   
your years of experience                                            1.000000   
your monthly income                                                 0.084645   
both hormonal and copper IUD are safe to use wh...                  0.115858   
We must advise the patient to take iron-contain...                 -0.051582   

                                                    your monthly income   \
result                                                          0.030953   
Your age                                                        0.276482   
your years of experience                                        0.084645   
your monthly income                                             1.000000   
both hormonal and copper IUD are safe to use wh...              0.047521   
We must advise the patient to take iron-contain...             -0.001421   

                                                    both hormonal and copper IUD are safe to use while breastfeeding.  \
result                                                                                       0.211815                   
Your age                                                                                     0.094385                   
your years of experience                                                                     0.115858                   
your monthly income                                                                          0.047521                   
both hormonal and copper IUD are safe to use wh...                                           1.000000                   
We must advise the patient to take iron-contain...                                           0.275428                   

                                                    We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD  
result                                                                                       0.286821                                                           
Your age                                                                                    -0.063612                                                           
your years of experience                                                                    -0.051582                                                           
your monthly income                                                                         -0.001421                                                           
both hormonal and copper IUD are safe to use wh...                                           0.275428                                                           
We must advise the patient to take iron-contain...                                           1.000000                                                           
In [16]:
print(dc_df.columns)
Index(['طابع زمني', 'result', 'Your age ', 'your years of experience',
       'your monthly income ', 'your  gender_Female', 'your  gender_Male',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Normalizing erratic menstrual cycles',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Prophylaxis of pelvic inflammatory disease',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Treatment of endometrial cancer',
       'women cant use a copper IUD if she  _all of above',
       'women cant use a copper IUD if she  _have Severe anemia',
       'women cant use a copper IUD if she  _have Wilson’s disease, which causes the body hold too much copper.',
       'women cant use a copper IUD if she  _have an allergy to copper',
       'one of the following is consider as advantage of hormonal IUD _all of above',
       'one of the following is consider as advantage of hormonal IUD _it protect  against sexually transmitted infections',
       'one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.',
       'one of the following is consider as advantage of hormonal IUD _women who have recent pelvic infection can use it',
       'An IUD can be inserted  _at Ovulation days (14-16).',
       'An IUD can be inserted  _at any time .',
       'An IUD can be inserted  _during the period or at the day after your period finish',
       'both hormonal and copper IUD are safe to use while breastfeeding._0.0',
       'both hormonal and copper IUD are safe to use while breastfeeding._1.0',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_0.0',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0',
       'IUD Can be used by women of any age, including adolescents._Agree',
       'IUD Can be used by women of any age, including adolescents._Disagree',
       'IUD Can be used by women of any age, including adolescents._I dont know',
       'IUD Can not be used by women who have not had   children _Agree',
       'IUD Can not be used by women who have not had   children _Disagree',
       'IUD Can not be used by women who have not had   children _I dont know',
       'IUD increase the risk of contracting STIs, including HIV\n_Agree',
       'IUD increase the risk of contracting STIs, including HIV\n_Disagree',
       'IUD increase the risk of contracting STIs, including HIV\n_I dont know',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Disagree',
       'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_I dont know',
       'IUD make women infertile._Agree', 'IUD make women infertile._Disagree',
       'IUD make women infertile._I dont know',
       'IUD  cause birth defects._Agree', 'IUD  cause birth defects._Disagree',
       'IUD  cause birth defects._I do not know',
       'IUD Do not cause cancer._Agree', 'IUD Do not cause cancer._Disagree',
       'IUD Do not cause cancer._I do not know',
       'IUD Do not move to the heart or brain_Agree',
       'IUD Do not move to the heart or brain_Disagree',
       'IUD Do not move to the heart or brain_I do not know',
       'IUD cause discomfort or pain for the woman or the man during sex._Agree',
       'IUD cause discomfort or pain for the woman or the man during sex._Disagree',
       'IUD cause discomfort or pain for the woman or the man during sex._I do not know',
       'IUD Substantially reduce the risk of ectopic pregnancy._Agree',
       'IUD Substantially reduce the risk of ectopic pregnancy._Disagree',
       'IUD Substantially reduce the risk of ectopic pregnancy._I do not know',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Reassure her that many women using IUDs experience this symptoms',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Use NSAIDs to treat fever and pain.',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should Regularly check her blood strength and ferretin levels.',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should take iron supplement to avoid anemia',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should use hormonal iud insted If it keep going in this manner for long period',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Reassure her that many women eventually stop having monthly bleeding when using the hormonal IUD, and this is not harmful. It is not necessary to experience monthly blood loss.',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Take norethisterone 5mg/12 hrs',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition',
       'A woman has acne while using an IUD. What is your advice?_all of above',
       'A woman has acne while using an IUD. What is your advice?_consider locally available remedies',
       'A woman has acne while using an IUD. What is your advice?_suggest switching to COCs. Many women’s acne improves with COCs use',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Consult a gynecologist',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Use a hot water bottle or a heating pad set on low on your belly for pain.',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b',
       'what is your information source/s about IUD ?_My university studies',
       'what is your information source/s about IUD ?_My university studies, Research',
       'what is your information source/s about IUD ?_My university studies, Self experience',
       'what is your information source/s about IUD ?_My university studies, Self experience, Research',
       'what is your information source/s about IUD ?_Research',
       'what is your information source/s about IUD ?_Self experience',
       'what is your information source/s about IUD ?_Self experience, Research'],
      dtype='object')

The P value calulated for all questions and age column¶

In [17]:
columns_to_iterate = dc_df.columns[5:]
for column in columns_to_iterate:
    group1 = dc_df[dc_df[column]]['Your age ']
    group2 = dc_df[~dc_df[column]]['Your age ']
    t_statistic, p_value = stats.ttest_ind(group1, group2)
    print(f"\n{column},Age")
    print(f"\nT-statistic: {t_statistic}, p-value: {p_value}")
your  gender_Female,Age

T-statistic: -1.3488847798304557, p-value: 0.17834903641417177

your  gender_Male,Age

T-statistic: 1.3488847798304557, p-value: 0.17834903641417177

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Normalizing erratic menstrual cycles,Age

T-statistic: -0.6661880706596448, p-value: 0.5057815968836673

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Prophylaxis of pelvic inflammatory disease,Age

T-statistic: 0.8676213743814812, p-value: 0.38626632765145796

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding,Age

T-statistic: 0.9591571736395221, p-value: 0.3382198819376684

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Treatment of endometrial cancer,Age

T-statistic: -1.726986071682496, p-value: 0.08515673862315769

women cant use a copper IUD if she  _all of above,Age

T-statistic: -0.9919942813691464, p-value: 0.32196656143476865

women cant use a copper IUD if she  _have Severe anemia,Age

T-statistic: 1.2148875713263614, p-value: 0.22532465036417648

women cant use a copper IUD if she  _have Wilson’s disease, which causes the body hold too much copper.,Age

T-statistic: -0.7220552672249462, p-value: 0.4707995835412607

women cant use a copper IUD if she  _have an allergy to copper,Age

T-statistic: 0.5740525576336685, p-value: 0.5663445221729115

one of the following is consider as advantage of hormonal IUD _all of above,Age

T-statistic: -1.3526097433396493, p-value: 0.17715665698992936

one of the following is consider as advantage of hormonal IUD _it protect  against sexually transmitted infections,Age

T-statistic: 0.12275883460847536, p-value: 0.9023768564958673

one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.,Age

T-statistic: -0.12786711492483657, p-value: 0.8983362487637798

one of the following is consider as advantage of hormonal IUD _women who have recent pelvic infection can use it,Age

T-statistic: 1.0519747231604142, p-value: 0.29362261077618396

An IUD can be inserted  _at Ovulation days (14-16).,Age

T-statistic: -0.16408192859840562, p-value: 0.8697725514601726

An IUD can be inserted  _at any time .,Age

T-statistic: -0.2753860292944598, p-value: 0.7832013834627478

An IUD can be inserted  _during the period or at the day after your period finish,Age

T-statistic: 0.439796205271549, p-value: 0.6603882280786447

both hormonal and copper IUD are safe to use while breastfeeding._0.0,Age

T-statistic: -1.6773223604332435, p-value: 0.09447774485746535

both hormonal and copper IUD are safe to use while breastfeeding._1.0,Age

T-statistic: 1.6773223604332435, p-value: 0.09447774485746535

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_0.0,Age

T-statistic: 1.1276907434360786, p-value: 0.26031424527333413

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0,Age

T-statistic: -1.1276907434360786, p-value: 0.26031424527333413

IUD Can be used by women of any age, including adolescents._Agree,Age

T-statistic: -0.802461103188255, p-value: 0.4228951475767936

IUD Can be used by women of any age, including adolescents._Disagree,Age

T-statistic: 1.205875624548014, p-value: 0.22877620573395907

IUD Can be used by women of any age, including adolescents._I dont know,Age

T-statistic: -0.598234329015205, p-value: 0.5501162212493839

IUD Can not be used by women who have not had   children _Agree,Age

T-statistic: 1.6306865951480782, p-value: 0.10396226385230614

IUD Can not be used by women who have not had   children _Disagree,Age

T-statistic: -0.9841221526390095, p-value: 0.325815554028243

IUD Can not be used by women who have not had   children _I dont know,Age

T-statistic: -0.9684580269798755, p-value: 0.3335634035571452

IUD increase the risk of contracting STIs, including HIV
_Agree,Age

T-statistic: -0.5932191719020709, p-value: 0.5534628809555395

IUD increase the risk of contracting STIs, including HIV
_Disagree,Age

T-statistic: 1.0094979308360759, p-value: 0.313515642613582

IUD increase the risk of contracting STIs, including HIV
_I dont know,Age

T-statistic: -0.5877422973638184, p-value: 0.5571290612380722

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree,Age

T-statistic: 0.03867484088350815, p-value: 0.9691742879885017

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Disagree,Age

T-statistic: 0.04913028703025675, p-value: 0.9608468022570072

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_I dont know,Age

T-statistic: -0.12769459414216686, p-value: 0.8984726686858728

IUD make women infertile._Agree,Age

T-statistic: 2.2929777674742255, p-value: 0.022512108151919945

IUD make women infertile._Disagree,Age

T-statistic: -1.389332790821058, p-value: 0.16571912811978706

IUD make women infertile._I dont know,Age

T-statistic: -0.9919942813691462, p-value: 0.32196656143476865

IUD  cause birth defects._Agree,Age

T-statistic: 2.211939952017267, p-value: 0.027692765324047176

IUD  cause birth defects._Disagree,Age

T-statistic: -0.767934987992124, p-value: 0.44310476094691054

IUD  cause birth defects._I do not know,Age

T-statistic: -1.7446974046199362, p-value: 0.08201906188508494

IUD Do not cause cancer._Agree,Age

T-statistic: -0.45047045813459674, p-value: 0.652683117915057

IUD Do not cause cancer._Disagree,Age

T-statistic: 1.3404739640476957, p-value: 0.18106343585646265

IUD Do not cause cancer._I do not know,Age

T-statistic: -1.0149394172989128, p-value: 0.31091860472549665

IUD Do not move to the heart or brain_Agree,Age

T-statistic: 0.6045495653445596, p-value: 0.5459163037144712

IUD Do not move to the heart or brain_Disagree,Age

T-statistic: 0.20584517980076797, p-value: 0.8370456677510618

IUD Do not move to the heart or brain_I do not know,Age

T-statistic: -1.0254586101127783, p-value: 0.3059386935262509

IUD cause discomfort or pain for the woman or the man during sex._Agree,Age

T-statistic: -0.7613691685814042, p-value: 0.44700984643764874

IUD cause discomfort or pain for the woman or the man during sex._Disagree,Age

T-statistic: 1.009539774477671, p-value: 0.3134956174824684

IUD cause discomfort or pain for the woman or the man during sex._I do not know,Age

T-statistic: -0.2869663607397063, p-value: 0.7743279522862127

IUD Substantially reduce the risk of ectopic pregnancy._Agree,Age

T-statistic: 0.1818157937897788, p-value: 0.8558449782502138

IUD Substantially reduce the risk of ectopic pregnancy._Disagree,Age

T-statistic: -0.29561832301946367, p-value: 0.7677175942158537

IUD Substantially reduce the risk of ectopic pregnancy._I do not know,Age

T-statistic: 0.16228848524973608, p-value: 0.8711833989064988

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.,Age

T-statistic: 0.10987956802100898, p-value: 0.912575302130674

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Reassure her that many women using IUDs experience this symptoms,Age

T-statistic: -0.830118627316474, p-value: 0.40710441043591894

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Use NSAIDs to treat fever and pain.,Age

T-statistic: 0.6238940673942993, p-value: 0.5331515779867239

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above,Age

T-statistic: -1.0675773428820827, p-value: 0.28653391303685255

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should Regularly check her blood strength and ferretin levels.,Age

T-statistic: -1.8334913952391918, p-value: 0.0676790006872004

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should take iron supplement to avoid anemia,Age

T-statistic: -1.0117136231866566, p-value: 0.3124564411038082

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should use hormonal iud insted If it keep going in this manner for long period,Age

T-statistic: 2.6196556284506802, p-value: 0.009230739375237853

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Reassure her that many women eventually stop having monthly bleeding when using the hormonal IUD, and this is not harmful. It is not necessary to experience monthly blood loss.,Age

T-statistic: 0.32132482995861766, p-value: 0.7481787009494459

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Take norethisterone 5mg/12 hrs,Age

T-statistic: -0.44159379288611006, p-value: 0.6590880915302433

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition,Age

T-statistic: -0.03423508878969849, p-value: 0.972711507749205

A woman has acne while using an IUD. What is your advice?_all of above,Age

T-statistic: -0.5581101884587931, p-value: 0.5771681261500761

A woman has acne while using an IUD. What is your advice?_consider locally available remedies,Age

T-statistic: -1.3419926094999999, p-value: 0.1805710610958226

A woman has acne while using an IUD. What is your advice?_suggest switching to COCs. Many women’s acne improves with COCs use,Age

T-statistic: 1.6151310133717711, p-value: 0.10728985775814281

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Consult a gynecologist,Age

T-statistic: -0.7892560156851678, p-value: 0.4305598314022788

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen,Age

T-statistic: 0.6611094165253614, p-value: 0.509028470325096

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Use a hot water bottle or a heating pad set on low on your belly for pain.,Age

T-statistic: 0.8595704137086638, p-value: 0.39068374557643804

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b,Age

T-statistic: -1.4286049123810267, p-value: 0.15411495238290485

what is your information source/s about IUD ?_My university studies,Age

T-statistic: -0.35843833900769656, p-value: 0.7202569351621311

what is your information source/s about IUD ?_My university studies, Research,Age

T-statistic: -1.259537852016453, p-value: 0.20877452667082463

what is your information source/s about IUD ?_My university studies, Self experience,Age

T-statistic: -0.29496267654699887, p-value: 0.7682179403864425

what is your information source/s about IUD ?_My university studies, Self experience, Research,Age

T-statistic: -0.961831441888215, p-value: 0.33687673147935604

what is your information source/s about IUD ?_Research,Age

T-statistic: 0.6005130178892024, p-value: 0.548598947613487

what is your information source/s about IUD ?_Self experience,Age

T-statistic: 1.0796953582084035, p-value: 0.28110913330981857

what is your information source/s about IUD ?_Self experience, Research,Age

T-statistic: 0.6611094165253614, p-value: 0.509028470325096

The P value calulated for all questions and Years of Experience column¶

In [18]:
columns_to_iterate = dc_df.columns[5:]
for column in columns_to_iterate:
    group1 = dc_df[dc_df[column]]['your years of experience']
    group2 = dc_df[~dc_df[column]]['your years of experience']
    t_statistic, p_value = stats.ttest_ind(group1, group2)
    print(f"\n{column},years of experience")
    print(f"\nT-statistic: {t_statistic}, p-value: {p_value}")
your  gender_Female,years of experience

T-statistic: -1.1890684060527852, p-value: 0.23531403945875737

your  gender_Male,years of experience

T-statistic: 1.1890684060527852, p-value: 0.23531403945875737

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Normalizing erratic menstrual cycles,years of experience

T-statistic: -1.2619219267997726, p-value: 0.20791641440027137

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Prophylaxis of pelvic inflammatory disease,years of experience

T-statistic: 1.6450448153160961, p-value: 0.10096442059399377

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding,years of experience

T-statistic: 0.607489859647711, p-value: 0.5439663400340944

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Treatment of endometrial cancer,years of experience

T-statistic: -1.7022465761635874, p-value: 0.08970202880453458

women cant use a copper IUD if she  _all of above,years of experience

T-statistic: -1.0563382161800634, p-value: 0.2916283529684504

women cant use a copper IUD if she  _have Severe anemia,years of experience

T-statistic: 0.7196037010293594, p-value: 0.4723059875844168

women cant use a copper IUD if she  _have Wilson’s disease, which causes the body hold too much copper.,years of experience

T-statistic: 0.0827445805128481, p-value: 0.9341075266746869

women cant use a copper IUD if she  _have an allergy to copper,years of experience

T-statistic: 0.19597505807908455, p-value: 0.8447568583142

one of the following is consider as advantage of hormonal IUD _all of above,years of experience

T-statistic: -1.021535475248494, p-value: 0.30778970426380886

one of the following is consider as advantage of hormonal IUD _it protect  against sexually transmitted infections,years of experience

T-statistic: -0.14274474817244506, p-value: 0.8865836195034578

one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.,years of experience

T-statistic: -0.5580451114311762, p-value: 0.5772125082552533

one of the following is consider as advantage of hormonal IUD _women who have recent pelvic infection can use it,years of experience

T-statistic: 1.4175160171062553, p-value: 0.15732679820048304

An IUD can be inserted  _at Ovulation days (14-16).,years of experience

T-statistic: 0.108188336352418, p-value: 0.9139156159644408

An IUD can be inserted  _at any time .,years of experience

T-statistic: -0.22383313531427318, p-value: 0.8230331721681374

An IUD can be inserted  _during the period or at the day after your period finish,years of experience

T-statistic: 0.10020655092089012, p-value: 0.9202444980503253

both hormonal and copper IUD are safe to use while breastfeeding._0.0,years of experience

T-statistic: -2.063638383626204, p-value: 0.03987609703706024

both hormonal and copper IUD are safe to use while breastfeeding._1.0,years of experience

T-statistic: 2.063638383626204, p-value: 0.03987609703706024

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_0.0,years of experience

T-statistic: 0.9137936839214927, p-value: 0.36152862513258244

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0,years of experience

T-statistic: -0.9137936839214927, p-value: 0.36152862513258244

IUD Can be used by women of any age, including adolescents._Agree,years of experience

T-statistic: -0.7016184851439952, p-value: 0.4834384653121081

IUD Can be used by women of any age, including adolescents._Disagree,years of experience

T-statistic: 1.7508365474933247, p-value: 0.08095371296943824

IUD Can be used by women of any age, including adolescents._I dont know,years of experience

T-statistic: -1.295442996455383, p-value: 0.19612204253807566

IUD Can not be used by women who have not had   children _Agree,years of experience

T-statistic: 1.2606437907646535, p-value: 0.20837614033995572

IUD Can not be used by women who have not had   children _Disagree,years of experience

T-statistic: -0.22023957323072102, p-value: 0.8258281564138361

IUD Can not be used by women who have not had   children _I dont know,years of experience

T-statistic: -1.5337975730012283, p-value: 0.12608959774174258

IUD increase the risk of contracting STIs, including HIV
_Agree,years of experience

T-statistic: -0.14135109415584926, p-value: 0.8876835183541202

IUD increase the risk of contracting STIs, including HIV
_Disagree,years of experience

T-statistic: 0.7759163278624374, p-value: 0.4383842699116718

IUD increase the risk of contracting STIs, including HIV
_I dont know,years of experience

T-statistic: -0.9033283614139116, p-value: 0.3670463253591194

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree,years of experience

T-statistic: 0.9078672118864131, p-value: 0.3646468315936784

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Disagree,years of experience

T-statistic: -0.7486426637946157, p-value: 0.45463480086578

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_I dont know,years of experience

T-statistic: -0.24871683180306514, p-value: 0.8037429427260614

IUD make women infertile._Agree,years of experience

T-statistic: 2.4528989163199784, p-value: 0.014716305883136643

IUD make women infertile._Disagree,years of experience

T-statistic: -0.9930854339596448, p-value: 0.32143541679051285

IUD make women infertile._I dont know,years of experience

T-statistic: -1.6818083904785694, p-value: 0.09360338075331835

IUD  cause birth defects._Agree,years of experience

T-statistic: 2.497025816322135, p-value: 0.013037542541870333

IUD  cause birth defects._Disagree,years of experience

T-statistic: -0.42237855424954557, p-value: 0.6730387235449358

IUD  cause birth defects._I do not know,years of experience

T-statistic: -2.5448076598831713, p-value: 0.011413665039568432

IUD Do not cause cancer._Agree,years of experience

T-statistic: -0.5458528314589413, p-value: 0.5855559216767906

IUD Do not cause cancer._Disagree,years of experience

T-statistic: 1.772098716051652, p-value: 0.07735094867282258

IUD Do not cause cancer._I do not know,years of experience

T-statistic: -1.3957505931214453, p-value: 0.16377890282803304

IUD Do not move to the heart or brain_Agree,years of experience

T-statistic: 0.7162612997268824, p-value: 0.4743640705241966

IUD Do not move to the heart or brain_Disagree,years of experience

T-statistic: 0.6891938706512177, p-value: 0.4912118523218777

IUD Do not move to the heart or brain_I do not know,years of experience

T-statistic: -1.7649116210989506, p-value: 0.07855378968347432

IUD cause discomfort or pain for the woman or the man during sex._Agree,years of experience

T-statistic: -0.8865406620625241, p-value: 0.376006895878943

IUD cause discomfort or pain for the woman or the man during sex._Disagree,years of experience

T-statistic: 1.4516767269452306, p-value: 0.14759308232029364

IUD cause discomfort or pain for the woman or the man during sex._I do not know,years of experience

T-statistic: -0.6707042304733932, p-value: 0.5029035629034737

IUD Substantially reduce the risk of ectopic pregnancy._Agree,years of experience

T-statistic: 0.022346773328808862, p-value: 0.9821855776352593

IUD Substantially reduce the risk of ectopic pregnancy._Disagree,years of experience

T-statistic: -0.06827983495451256, p-value: 0.945606473492481

IUD Substantially reduce the risk of ectopic pregnancy._I do not know,years of experience

T-statistic: 0.0659086045150903, p-value: 0.9474926668355781

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.,years of experience

T-statistic: 0.014978666193019068, p-value: 0.9880587433522545

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Reassure her that many women using IUDs experience this symptoms,years of experience

T-statistic: -0.7637748855446039, p-value: 0.4455767442792874

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Use NSAIDs to treat fever and pain.,years of experience

T-statistic: 0.6597978284287173, p-value: 0.5098687710849809

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above,years of experience

T-statistic: -1.4199672878920042, p-value: 0.15661244664846982

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should Regularly check her blood strength and ferretin levels.,years of experience

T-statistic: -1.3278451904534632, p-value: 0.1851967840608335

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should take iron supplement to avoid anemia,years of experience

T-statistic: -1.5246993246386025, p-value: 0.12834385548546123

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should use hormonal iud insted If it keep going in this manner for long period,years of experience

T-statistic: 2.9895399650820482, p-value: 0.003015449311670952

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Reassure her that many women eventually stop having monthly bleeding when using the hormonal IUD, and this is not harmful. It is not necessary to experience monthly blood loss.,years of experience

T-statistic: -0.356505605754833, p-value: 0.7217021541067026

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Take norethisterone 5mg/12 hrs,years of experience

T-statistic: 0.17718909165734856, p-value: 0.8594744684220347

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition,years of experience

T-statistic: 0.22757989207814594, p-value: 0.8201214376505432

A woman has acne while using an IUD. What is your advice?_all of above,years of experience

T-statistic: -0.9960523983844047, p-value: 0.3199940845800178

A woman has acne while using an IUD. What is your advice?_consider locally available remedies,years of experience

T-statistic: -1.2788410764584737, p-value: 0.20190036619133495

A woman has acne while using an IUD. What is your advice?_suggest switching to COCs. Many women’s acne improves with COCs use,years of experience

T-statistic: 1.9247958803330265, p-value: 0.05516103469418819

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Consult a gynecologist,years of experience

T-statistic: -1.0173647290684154, p-value: 0.30976569323862174

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen,years of experience

T-statistic: 0.03307812753350358, p-value: 0.973633368256809

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Use a hot water bottle or a heating pad set on low on your belly for pain.,years of experience

T-statistic: 0.9341933505912559, p-value: 0.35092428672881326

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b,years of experience

T-statistic: -0.557648655508145, p-value: 0.5774829234809151

what is your information source/s about IUD ?_My university studies,years of experience

T-statistic: 0.39407232139676474, p-value: 0.6937959849813473

what is your information source/s about IUD ?_My university studies, Research,years of experience

T-statistic: -1.8811499487103758, p-value: 0.0608795853904947

what is your information source/s about IUD ?_My university studies, Self experience,years of experience

T-statistic: -0.6038702788218798, p-value: 0.5463672921262506

what is your information source/s about IUD ?_My university studies, Self experience, Research,years of experience

T-statistic: 0.4146793945118212, p-value: 0.6786606848662636

what is your information source/s about IUD ?_Research,years of experience

T-statistic: -0.13432700225790167, p-value: 0.8932303338609706

what is your information source/s about IUD ?_Self experience,years of experience

T-statistic: 0.6310963150711335, p-value: 0.5284381200920811

what is your information source/s about IUD ?_Self experience, Research,years of experience

T-statistic: 0.9937101544190747, p-value: 0.32113157811506055
In [19]:
columns_to_iterate = dc_df.columns[5:]
for column in columns_to_iterate:
    group1 = dc_df[dc_df[column]]['result']
    group2 = dc_df[~dc_df[column]]['result']
    t_statistic, p_value = stats.ttest_ind(group1, group2)
    print(f"\n{column},results")
    print(f"\nT-statistic: {t_statistic}, p-value: {p_value}")
your  gender_Female,results

T-statistic: -0.2487606551101402, p-value: 0.803709072224414

your  gender_Male,results

T-statistic: 0.2487606551101402, p-value: 0.803709072224414

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Normalizing erratic menstrual cycles,results

T-statistic: -1.1059461183076433, p-value: 0.26959915638226195

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Prophylaxis of pelvic inflammatory disease,results

T-statistic: -2.1641930627802948, p-value: 0.031205491560566085

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding,results

T-statistic: 4.416359146651675, p-value: 1.3843243905734676e-05

Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Treatment of endometrial cancer,results

T-statistic: -1.8476208418887985, p-value: 0.06560062769355417

women cant use a copper IUD if she  _all of above,results

T-statistic: 6.778880011684844, p-value: 6.032739978241884e-11

women cant use a copper IUD if she  _have Severe anemia,results

T-statistic: -1.3512655645902183, p-value: 0.17758624535443565

women cant use a copper IUD if she  _have Wilson’s disease, which causes the body hold too much copper.,results

T-statistic: -2.7115106252407557, p-value: 0.007067672083066236

women cant use a copper IUD if she  _have an allergy to copper,results

T-statistic: -1.5752671623502228, p-value: 0.11620496582549518

one of the following is consider as advantage of hormonal IUD _all of above,results

T-statistic: -1.1512024118408375, p-value: 0.25052761228213255

one of the following is consider as advantage of hormonal IUD _it protect  against sexually transmitted infections,results

T-statistic: -0.9664471590063524, p-value: 0.3345666081869977

one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.,results

T-statistic: 2.731215823844696, p-value: 0.00666798817516711

one of the following is consider as advantage of hormonal IUD _women who have recent pelvic infection can use it,results

T-statistic: -0.4297617675746054, p-value: 0.6676646535654134

An IUD can be inserted  _at Ovulation days (14-16).,results

T-statistic: -0.9096569829413284, p-value: 0.3637033707140487

An IUD can be inserted  _at any time .,results

T-statistic: -4.541869131786291, p-value: 7.967921157712259e-06

An IUD can be inserted  _during the period or at the day after your period finish,results

T-statistic: 5.441071847648454, p-value: 1.0701192177211295e-07

both hormonal and copper IUD are safe to use while breastfeeding._0.0,results

T-statistic: -3.8343883652293234, p-value: 0.00015219751318066728

both hormonal and copper IUD are safe to use while breastfeeding._1.0,results

T-statistic: 3.8343883652293234, p-value: 0.00015219751318066728

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_0.0,results

T-statistic: -5.29692715446929, p-value: 2.2242033445366648e-07

We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0,results

T-statistic: 5.29692715446929, p-value: 2.2242033445366648e-07

IUD Can be used by women of any age, including adolescents._Agree,results

T-statistic: 6.08234148642165, p-value: 3.450182860094888e-09

IUD Can be used by women of any age, including adolescents._Disagree,results

T-statistic: -1.0038199150395153, p-value: 0.31624081849353786

IUD Can be used by women of any age, including adolescents._I dont know,results

T-statistic: -4.33748729316961, p-value: 1.946404457226485e-05

IUD Can not be used by women who have not had   children _Agree,results

T-statistic: -0.6457033962261877, p-value: 0.5189445394820585

IUD Can not be used by women who have not had   children _Disagree,results

T-statistic: 3.375864882220516, p-value: 0.0008285877636989745

IUD Can not be used by women who have not had   children _I dont know,results

T-statistic: -3.9250860785684565, p-value: 0.00010664690763735382

IUD increase the risk of contracting STIs, including HIV
_Agree,results

T-statistic: -2.084813198614237, p-value: 0.03789648353257576

IUD increase the risk of contracting STIs, including HIV
_Disagree,results

T-statistic: 3.9246418958010136, p-value: 0.00010683456923689464

IUD increase the risk of contracting STIs, including HIV
_I dont know,results

T-statistic: -2.5209038719357264, p-value: 0.012202008624731158

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree,results

T-statistic: 4.484566227990628, p-value: 1.026919927573246e-05

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Disagree,results

T-statistic: -1.077647605066103, p-value: 0.2820208832175655

IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_I dont know,results

T-statistic: -5.009140651017899, p-value: 9.15458216996313e-07

IUD make women infertile._Agree,results

T-statistic: -0.8058160668332996, p-value: 0.42096067855527686

IUD make women infertile._Disagree,results

T-statistic: 6.590176202535901, p-value: 1.8626137276530518e-10

IUD make women infertile._I dont know,results

T-statistic: -7.391786993689922, p-value: 1.3320305038614017e-12

IUD  cause birth defects._Agree,results

T-statistic: -1.5706318392489835, p-value: 0.11727850309040998

IUD  cause birth defects._Disagree,results

T-statistic: 6.953199805883328, p-value: 2.0873827881663736e-11

IUD  cause birth defects._I do not know,results

T-statistic: -6.751603179331862, p-value: 7.110362231306134e-11

IUD Do not cause cancer._Agree,results

T-statistic: 4.966033138826603, p-value: 1.1255431892663408e-06

IUD Do not cause cancer._Disagree,results

T-statistic: -0.529265915576314, p-value: 0.596996152759845

IUD Do not cause cancer._I do not know,results

T-statistic: -4.983987854243533, p-value: 1.0329168626119028e-06

IUD Do not move to the heart or brain_Agree,results

T-statistic: 7.699829526944001, p-value: 1.8030775436212472e-13

IUD Do not move to the heart or brain_Disagree,results

T-statistic: -2.343635555883794, p-value: 0.019722265260298636

IUD Do not move to the heart or brain_I do not know,results

T-statistic: -6.6014776413177785, p-value: 1.7421173288219627e-10

IUD cause discomfort or pain for the woman or the man during sex._Agree,results

T-statistic: 0.22753335226060498, p-value: 0.8201575901679948

IUD cause discomfort or pain for the woman or the man during sex._Disagree,results

T-statistic: 3.859445689669906, p-value: 0.00013804661752742295

IUD cause discomfort or pain for the woman or the man during sex._I do not know,results

T-statistic: -5.120524189630083, p-value: 5.333307004003658e-07

IUD Substantially reduce the risk of ectopic pregnancy._Agree,results

T-statistic: 4.535388550229193, p-value: 8.200926663137623e-06

IUD Substantially reduce the risk of ectopic pregnancy._Disagree,results

T-statistic: -2.339521426597963, p-value: 0.01993694621407216

IUD Substantially reduce the risk of ectopic pregnancy._I do not know,results

T-statistic: -3.0621215535486597, p-value: 0.002388405017943516

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.,results

T-statistic: 6.464445948844568, p-value: 3.8980363913009486e-10

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Reassure her that many women using IUDs experience this symptoms,results

T-statistic: -3.5554400205574046, p-value: 0.00043562441503115925

A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Use NSAIDs to treat fever and pain.,results

T-statistic: -2.9939204745227674, p-value: 0.0029736948612548845

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above,results

T-statistic: 5.069039578420924, p-value: 6.854198502596621e-07

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should Regularly check her blood strength and ferretin levels.,results

T-statistic: -1.6832018384815783, p-value: 0.09333311779716089

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should take iron supplement to avoid anemia,results

T-statistic: -1.050423345013746, p-value: 0.29433385088697

WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _she should use hormonal iud insted If it keep going in this manner for long period,results

T-statistic: -1.2447457584209147, p-value: 0.21415640253761567

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Reassure her that many women eventually stop having monthly bleeding when using the hormonal IUD, and this is not harmful. It is not necessary to experience monthly blood loss.,results

T-statistic: -0.5579716015782574, p-value: 0.5772626434347543

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_Take norethisterone 5mg/12 hrs,results

T-statistic: -0.3188859525917643, p-value: 0.7500256932564954

A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition,results

T-statistic: 0.7181413867416641, p-value: 0.47320579866768175

A woman has acne while using an IUD. What is your advice?_all of above,results

T-statistic: 3.115118843408284, p-value: 0.002008925574270821

A woman has acne while using an IUD. What is your advice?_consider locally available remedies,results

T-statistic: -1.438596433952305, p-value: 0.15126405892548944

A woman has acne while using an IUD. What is your advice?_suggest switching to COCs. Many women’s acne improves with COCs use,results

T-statistic: -1.2928342222685767, p-value: 0.19702187862946646

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Consult a gynecologist,results

T-statistic: 1.4523710486377908, p-value: 0.1474001505546293

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Take an over-the-counter pain medicine, such as acetaminophen , ibuprofen , and naproxen,results

T-statistic: -2.1539263082264877, p-value: 0.03200910368107385

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_Use a hot water bottle or a heating pad set on low on your belly for pain.,results

T-statistic: -2.191891729283136, p-value: 0.029123653507845793

For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b,results

T-statistic: 4.796860828114795, p-value: 2.4978183110521858e-06

what is your information source/s about IUD ?_My university studies,results

T-statistic: 0.3733019207440101, p-value: 0.7091764437943961

what is your information source/s about IUD ?_My university studies, Research,results

T-statistic: -1.262899955269022, p-value: 0.2075651320099215

what is your information source/s about IUD ?_My university studies, Self experience,results

T-statistic: 0.5312111884423671, p-value: 0.5956491933206925

what is your information source/s about IUD ?_My university studies, Self experience, Research,results

T-statistic: 3.2780816975668423, p-value: 0.0011627248684248888

what is your information source/s about IUD ?_Research,results

T-statistic: 0.17852020206619712, p-value: 0.8584299483946588

what is your information source/s about IUD ?_Self experience,results

T-statistic: 0.5989999481159519, p-value: 0.5496061992602139

what is your information source/s about IUD ?_Self experience, Research,results

T-statistic: -1.9342555018639065, p-value: 0.05398283262954251
In [20]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='Your age ', y='your years of experience')
plt.title('Scatter Plot between Age and Years of Experience ')
plt.xlabel('Age')
plt.ylabel('Years of Experience')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'Your age ', 'your years of experience']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [21]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='Your age ', y='your monthly income ')
plt.title('Scatter Plot between Age and monthly income  ')
plt.xlabel('Age')
plt.ylabel('your monthly income ')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'Your age ', 'your monthly income ']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [22]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='your monthly income ', y='your years of experience')
plt.title('Scatter Plot between monthly income and Years of Experience ')
plt.xlabel('your monthly income ')
plt.ylabel('Years of Experience')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'your monthly income ', 'your years of experience']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [23]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='result', y='your monthly income ')
plt.title('Scatter Plot between result and monthly income  ')
plt.xlabel('result')
plt.ylabel('your monthly income ')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'result', 'your monthly income ']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [24]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='result', y='your years of experience')
plt.title('Scatter Plot between result and Years of Experience ')
plt.xlabel('result')
plt.ylabel('Years of Experience')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'result', 'your years of experience']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [25]:
# Assuming df is your DataFrame containing non-boolean variables

# Scatter plot between two non-boolean variables
plt.figure(figsize=(8, 6))
sns.scatterplot(data=df, x='Your age ', y='result')
plt.title('Scatter Plot between Age and result')
plt.xlabel('Age')
plt.ylabel('result')
plt.show()

# Pair plot to visualize relationships between all pairs of non-boolean variables
sns.pairplot(df[[ 'Your age ', 'result']])
plt.suptitle('Pair Plot of Non-Boolean Variables', y=1.02)
plt.show()
No description has been provided for this image
No description has been provided for this image
In [26]:
# Scatter plot between a boolean and a non-boolean variable
for column in columns_to_iterate:
    plt.figure()
    plt.pie(dc_df[column].value_counts(), labels=['False', 'True'], autopct='%1.1f%%', startangle=140)
    plt.title(f'Proportion of True and False Values for {column}')
    plt.axis('equal')
    plt.show()
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image

The P value calulated for all correct answers and age column¶

In [27]:
# Assuming dc_df is your DataFrame containing the data and selected_columns is the list of selected columns
selected_columns = ['result','Your age ', 'your years of experience',
       'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding',
                    'women cant use a copper IUD if she  _all of above','one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.',
        'An IUD can be inserted  _during the period or at the day after your period finish','both hormonal and copper IUD are safe to use while breastfeeding._1.0',
       'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0',
        'IUD Can be used by women of any age, including adolescents._Agree','IUD Can not be used by women who have not had   children _Agree',
        'IUD increase the risk of contracting STIs, including HIV\n_Disagree','IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree',
     'IUD make women infertile._Agree', 'IUD make women infertile._Disagree',
        'IUD  cause birth defects._Disagree','IUD Do not cause cancer._Disagree','IUD Do not move to the heart or brain_Disagree','IUD cause discomfort or pain for the woman or the man during sex._Disagree',
       'IUD Substantially reduce the risk of ectopic pregnancy._Agree',
       'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.',
       'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above',
       'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition',
       'A woman has acne while using an IUD. What is your advice?_all of above',
       'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b',
       ]

# Create an empty dictionary to store the results
results = {}

# Iterate over each column
for column in selected_columns:
    # Filter the DataFrame to include only the rows where the answer is true
    correct_answers_df = dc_df[dc_df[column] == True]
    
    # Perform your analysis on the filtered DataFrame
    # For example, you can calculate mean age, median year of experience, etc.
    mean_age = correct_answers_df['Your age '].mean()
    median_year_of_experience = correct_answers_df['your years of experience'].median()

    # Perform the t-test
    t_statistic, p_value = stats.ttest_ind(correct_answers_df['Your age '], correct_answers_df['your years of experience'])
    
    # Calculate the standard deviation
    age_std = correct_answers_df['Your age '].std()
    exp_std = correct_answers_df['your years of experience'].std()
    
    # Store the results in the dictionary
    results[column] = {'mean_age': mean_age, 'median_year_of_experience': median_year_of_experience ,'t_statistic': t_statistic, 'p_value': p_value, 'age_std': age_std, 'exp_std': exp_std}

# Print the results
for column, result in results.items():
    print(f"Column: {column}")
    print(f"Mean Age: {result['mean_age']}")
    print(f"Median Year of Experience: {result['median_year_of_experience']}")
    print(f"t-statistic: {result['t_statistic']}, p-value: {result['p_value']}")
    print(f"Age Standard Deviation: {result['age_std']}")
    print(f"Experience Standard Deviation: {result['exp_std']}")
    print()
    
Column: result
Mean Age: nan
Median Year of Experience: nan
t-statistic: nan, p-value: nan
Age Standard Deviation: nan
Experience Standard Deviation: nan

Column: Your age 
Mean Age: nan
Median Year of Experience: nan
t-statistic: nan, p-value: nan
Age Standard Deviation: nan
Experience Standard Deviation: nan

Column: your years of experience
Mean Age: 23.75
Median Year of Experience: 1.0
t-statistic: 36.945906403822335, p-value: 1.420331316985878e-26
Age Standard Deviation: 2.463060426921489
Experience Standard Deviation: 0.0

Column: Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
Mean Age: 33.99145299145299
Median Year of Experience: 9.0
t-statistic: 23.808478094523576, p-value: 3.187947852250597e-64
Age Standard Deviation: 7.7130607173311345
Experience Standard Deviation: 7.18933945695232

Column: women cant use a copper IUD if she  _all of above
Mean Age: 32.57377049180328
Median Year of Experience: 7.0
t-statistic: 15.676355697127141, p-value: 8.054102308987454e-31
Age Standard Deviation: 8.057003198860485
Experience Standard Deviation: 8.158581924353854

Column: one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
Mean Age: 33.33870967741935
Median Year of Experience: 8.0
t-statistic: 16.69127716592709, p-value: 2.7408203356251783e-33
Age Standard Deviation: 8.575496063435818
Experience Standard Deviation: 6.9158844668452915

Column: An IUD can be inserted  _during the period or at the day after your period finish
Mean Age: 33.734693877551024
Median Year of Experience: 8.5
t-statistic: 20.950572285698783, p-value: 1.0507209902440451e-51
Age Standard Deviation: 7.8248230709000675
Experience Standard Deviation: 7.690021568716834

Column: both hormonal and copper IUD are safe to use while breastfeeding._1.0
Mean Age: 33.94859813084112
Median Year of Experience: 9.0
t-statistic: 29.614697226246715, p-value: 1.7839900362946258e-105
Age Standard Deviation: 8.095798069513833
Experience Standard Deviation: 7.906381327294931

Column: We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
Mean Age: 33.14912280701754
Median Year of Experience: 8.0
t-statistic: 32.39418601177289, p-value: 4.052120082985607e-120
Age Standard Deviation: 7.669072227503596
Experience Standard Deviation: 7.444242426526166

Column: IUD Can be used by women of any age, including adolescents._Agree
Mean Age: 32.8
Median Year of Experience: 8.5
t-statistic: 17.261994587155563, p-value: 2.7614456116568287e-36
Age Standard Deviation: 8.020986964461292
Experience Standard Deviation: 7.665823700168848

Column: IUD Can not be used by women who have not had   children _Agree
Mean Age: 34.204081632653065
Median Year of Experience: 9.0
t-statistic: 24.541628431428446, p-value: 6.08058225426379e-73
Age Standard Deviation: 8.302449527559563
Experience Standard Deviation: 7.894845200975599

Column: IUD increase the risk of contracting STIs, including HIV
_Disagree
Mean Age: 33.962406015037594
Median Year of Experience: 9.0
t-statistic: 25.01642141169494, p-value: 1.2888830108556224e-71
Age Standard Deviation: 7.723837575616735
Experience Standard Deviation: 7.351760956036651

Column: IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree
Mean Age: 33.46896551724138
Median Year of Experience: 9.0
t-statistic: 24.94239941100352, p-value: 6.2499086437743415e-74
Age Standard Deviation: 7.707369464434846
Experience Standard Deviation: 7.726972463279255

Column: IUD make women infertile._Agree
Mean Age: 34.80733944954128
Median Year of Experience: 9.0
t-statistic: 19.025507254531732, p-value: 4.6761143446356666e-48
Age Standard Deviation: 8.92300093206916
Experience Standard Deviation: 8.897746606040627

Column: IUD make women infertile._Disagree
Mean Age: 32.8
Median Year of Experience: 8.0
t-statistic: 26.73056971089806, p-value: 5.491798403544972e-80
Age Standard Deviation: 7.519973404208289
Experience Standard Deviation: 6.990867880061466

Column: IUD  cause birth defects._Disagree
Mean Age: 33.07857142857143
Median Year of Experience: 8.0
t-statistic: 24.248758097559598, p-value: 1.4789323504802376e-70
Age Standard Deviation: 8.122327214742734
Experience Standard Deviation: 7.617332260759795

Column: IUD Do not cause cancer._Disagree
Mean Age: 34.18032786885246
Median Year of Experience: 9.0
t-statistic: 22.177598358304664, p-value: 3.1555291375579484e-60
Age Standard Deviation: 8.274242012616572
Experience Standard Deviation: 7.779319765512293

Column: IUD Do not move to the heart or brain_Disagree
Mean Age: 33.57272727272727
Median Year of Experience: 8.0
t-statistic: 20.91838724151275, p-value: 4.996370412137387e-54
Age Standard Deviation: 8.408666445568366
Experience Standard Deviation: 7.6903208122394116

Column: IUD cause discomfort or pain for the woman or the man during sex._Disagree
Mean Age: 34.00833333333333
Median Year of Experience: 9.5
t-statistic: 24.666626982779096, p-value: 1.6320752149678335e-67
Age Standard Deviation: 7.0394994012875864
Experience Standard Deviation: 7.269866242378386

Column: IUD Substantially reduce the risk of ectopic pregnancy._Agree
Mean Age: 33.539568345323744
Median Year of Experience: 8.0
t-statistic: 24.442879753129198, p-value: 5.213673072110624e-71
Age Standard Deviation: 8.035488483884654
Experience Standard Deviation: 7.70109029839049

Column: A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
Mean Age: 33.51282051282051
Median Year of Experience: 8.0
t-statistic: 22.455377290441337, p-value: 4.1894016432341583e-60
Age Standard Deviation: 7.922703501282298
Experience Standard Deviation: 7.779058165841097

Column: WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
Mean Age: 32.142857142857146
Median Year of Experience: 9.0
t-statistic: 17.1829787290544, p-value: 1.9310652073393027e-26
Age Standard Deviation: 5.796260747711595
Experience Standard Deviation: 5.573032305274235

Column: A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
Mean Age: 33.43850267379679
Median Year of Experience: 8.0
t-statistic: 28.624719709697032, p-value: 4.711201468286843e-96
Age Standard Deviation: 7.77576977510413
Experience Standard Deviation: 7.699431279109866

Column: A woman has acne while using an IUD. What is your advice?_all of above
Mean Age: 32.985074626865675
Median Year of Experience: 8.0
t-statistic: 17.365921653572805, p-value: 6.758995474462797e-36
Age Standard Deviation: 7.930555671068844
Experience Standard Deviation: 7.615557228139652

Column: For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
Mean Age: 31.956521739130434
Median Year of Experience: 8.5
t-statistic: 14.811611746332842, p-value: 7.325927283636565e-26
Age Standard Deviation: 6.189440907219435
Experience Standard Deviation: 7.984830122006022

C:\Users\samir\miniconda3\Lib\site-packages\scipy\stats\_axis_nan_policy.py:523: RuntimeWarning: Precision loss occurred in moment calculation due to catastrophic cancellation. This occurs when the data are nearly identical. Results may be unreliable.
  res = hypotest_fun_out(*samples, **kwds)
In [28]:
# Select the columns from dc_df based on the selected_column names
selected_df = dc_df[selected_columns]

# Generate descriptive statistics for the selected columns
description = selected_df.describe()

# Print the descriptive statistics
print(description)
           result   Your age   your years of experience
count  315.000000  315.000000                315.000000
mean     8.320635   33.450794                 10.454286
std      3.518204    7.689431                  7.372829
min      2.000000   22.000000                  0.600000
25%      6.000000   28.000000                  5.000000
50%      8.000000   31.000000                  8.000000
75%     10.000000   38.000000                 14.000000
max     21.000000   63.000000                 45.000000

Here you will find simple analysis and the count for each column in details that is easily understandable¶

In [29]:
# Create an empty dictionary to store the counts
boolean_counts = {}

# Iterate over each boolean column
for column in selected_columns:
    # Calculate value counts for the column
    counts = dc_df[column].value_counts()
    
    # Store the counts in the dictionary
    boolean_counts[column] = counts

# Print the counts
for column, counts in boolean_counts.items():
    print(f"Column: {column}")
    print(counts)
    print()
Column: result
result
7     50
9     49
8     38
6     37
5     27
10    27
11    19
4     16
3     10
12     9
13     6
14     5
18     4
2      4
21     4
17     3
16     2
20     2
19     2
15     1
Name: count, dtype: int64

Column: Your age 
Your age 
29.0    35
30.0    26
28.0    23
34.0    19
32.0    18
33.0    15
31.0    15
42.0    15
27.0    14
26.0    13
25.0    11
35.0    10
23.0    10
39.0     9
41.0     9
44.0     9
37.0     8
24.0     8
36.0     6
38.0     5
45.0     5
43.0     4
22.0     4
46.0     4
40.0     3
53.0     3
55.0     3
51.0     3
60.0     2
54.0     1
49.0     1
47.0     1
56.0     1
63.0     1
50.0     1
Name: count, dtype: int64

Column: your years of experience
your years of experience
6.0     35
12.0    29
4.0     23
8.0     22
5.0     19
7.0     18
9.0     17
1.0     16
3.0     16
11.0    13
19.0    11
13.0     9
2.0      8
14.0     8
18.0     8
16.0     8
17.0     7
15.0     6
10.0     6
26.0     5
20.0     5
22.0     5
24.0     3
28.0     2
23.0     2
30.0     2
27.0     2
25.0     2
21.0     2
45.0     1
11.5     1
40.0     1
0.6      1
43.0     1
31.0     1
Name: count, dtype: int64

Column: Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
False    198
True     117
Name: count, dtype: int64

Column: women cant use a copper IUD if she  _all of above
women cant use a copper IUD if she  _all of above
False    254
True      61
Name: count, dtype: int64

Column: one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
False    253
True      62
Name: count, dtype: int64

Column: An IUD can be inserted  _during the period or at the day after your period finish
An IUD can be inserted  _during the period or at the day after your period finish
False    217
True      98
Name: count, dtype: int64

Column: both hormonal and copper IUD are safe to use while breastfeeding._1.0
both hormonal and copper IUD are safe to use while breastfeeding._1.0
True     214
False    101
Name: count, dtype: int64

Column: We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
True     228
False     87
Name: count, dtype: int64

Column: IUD Can be used by women of any age, including adolescents._Agree
IUD Can be used by women of any age, including adolescents._Agree
False    245
True      70
Name: count, dtype: int64

Column: IUD Can not be used by women who have not had   children _Agree
IUD Can not be used by women who have not had   children _Agree
False    168
True     147
Name: count, dtype: int64

Column: IUD increase the risk of contracting STIs, including HIV
_Disagree
IUD increase the risk of contracting STIs, including HIV\n_Disagree
False    182
True     133
Name: count, dtype: int64

Column: IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree
IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree
False    170
True     145
Name: count, dtype: int64

Column: IUD make women infertile._Agree
IUD make women infertile._Agree
False    206
True     109
Name: count, dtype: int64

Column: IUD make women infertile._Disagree
IUD make women infertile._Disagree
False    170
True     145
Name: count, dtype: int64

Column: IUD  cause birth defects._Disagree
IUD  cause birth defects._Disagree
False    175
True     140
Name: count, dtype: int64

Column: IUD Do not cause cancer._Disagree
IUD Do not cause cancer._Disagree
False    193
True     122
Name: count, dtype: int64

Column: IUD Do not move to the heart or brain_Disagree
IUD Do not move to the heart or brain_Disagree
False    205
True     110
Name: count, dtype: int64

Column: IUD cause discomfort or pain for the woman or the man during sex._Disagree
IUD cause discomfort or pain for the woman or the man during sex._Disagree
False    195
True     120
Name: count, dtype: int64

Column: IUD Substantially reduce the risk of ectopic pregnancy._Agree
IUD Substantially reduce the risk of ectopic pregnancy._Agree
False    176
True     139
Name: count, dtype: int64

Column: A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
False    198
True     117
Name: count, dtype: int64

Column: WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
False    280
True      35
Name: count, dtype: int64

Column: A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
True     187
False    128
Name: count, dtype: int64

Column: A woman has acne while using an IUD. What is your advice?_all of above
A woman has acne while using an IUD. What is your advice?_all of above
False    248
True      67
Name: count, dtype: int64

Column: For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
False    269
True      46
Name: count, dtype: int64

In [30]:
# Create an empty dictionary to store the percentages
true_percentages = {}

# Iterate over each boolean column
for column in selected_columns:
    # Calculate the total number of entries in the column
    total_entries = dc_df[column].count()
    
    # Calculate the number of True values in the column
    true_count = dc_df[column].sum()
    
    # Calculate the percentage of True values
    true_percentage = (true_count / total_entries) * 100
    
    # Store the percentage in the dictionary
    true_percentages[column] = true_percentage

# Print the percentages
for column, percentage in true_percentages.items():
    print(f"Column: {column}")
    print(f"Percentage of True values: {percentage:.2f}%")
    print()
Column: result
Percentage of True values: 832.06%

Column: Your age 
Percentage of True values: 3345.08%

Column: your years of experience
Percentage of True values: 1045.43%

Column: Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
Percentage of True values: 37.14%

Column: women cant use a copper IUD if she  _all of above
Percentage of True values: 19.37%

Column: one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
Percentage of True values: 19.68%

Column: An IUD can be inserted  _during the period or at the day after your period finish
Percentage of True values: 31.11%

Column: both hormonal and copper IUD are safe to use while breastfeeding._1.0
Percentage of True values: 67.94%

Column: We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
Percentage of True values: 72.38%

Column: IUD Can be used by women of any age, including adolescents._Agree
Percentage of True values: 22.22%

Column: IUD Can not be used by women who have not had   children _Agree
Percentage of True values: 46.67%

Column: IUD increase the risk of contracting STIs, including HIV
_Disagree
Percentage of True values: 42.22%

Column: IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree
Percentage of True values: 46.03%

Column: IUD make women infertile._Agree
Percentage of True values: 34.60%

Column: IUD make women infertile._Disagree
Percentage of True values: 46.03%

Column: IUD  cause birth defects._Disagree
Percentage of True values: 44.44%

Column: IUD Do not cause cancer._Disagree
Percentage of True values: 38.73%

Column: IUD Do not move to the heart or brain_Disagree
Percentage of True values: 34.92%

Column: IUD cause discomfort or pain for the woman or the man during sex._Disagree
Percentage of True values: 38.10%

Column: IUD Substantially reduce the risk of ectopic pregnancy._Agree
Percentage of True values: 44.13%

Column: A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
Percentage of True values: 37.14%

Column: WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
Percentage of True values: 11.11%

Column: A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
Percentage of True values: 59.37%

Column: A woman has acne while using an IUD. What is your advice?_all of above
Percentage of True values: 21.27%

Column: For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
Percentage of True values: 14.60%

In [31]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = dc_df.groupby(['your  gender_Female', 'your  gender_Male'])[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)
                                       result  Your age   \
your  gender_Female your  gender_Male                      
False               True                  881     3599.0   
True                False                1740     6938.0   

                                       your years of experience  \
your  gender_Female your  gender_Male                             
False               True                                 1171.0   
True                False                                2122.1   

                                       Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
your  gender_Female your  gender_Male                                                                                                                                                                                             
False               True                                                              48                                                                                                                                          
True                False                                                             69                                                                                                                                          

                                       women cant use a copper IUD if she  _all of above  \
your  gender_Female your  gender_Male                                                      
False               True                                                              15   
True                False                                                             46   

                                       one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
your  gender_Female your  gender_Male                                                                                                                                            
False               True                                                              23                                                                                         
True                False                                                             39                                                                                         

                                       An IUD can be inserted  _during the period or at the day after your period finish  \
your  gender_Female your  gender_Male                                                                                      
False               True                                                              38                                   
True                False                                                             60                                   

                                       both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
your  gender_Female your  gender_Male                                                                          
False               True                                                              75                       
True                False                                                            139                       

                                       We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
your  gender_Female your  gender_Male                                                                                                                   
False               True                                                              68                                                                
True                False                                                            160                                                                

                                       IUD Can be used by women of any age, including adolescents._Agree  \
your  gender_Female your  gender_Male                                                                      
False               True                                                              25                   
True                False                                                             45                   

                                       ...  \
your  gender_Female your  gender_Male  ...   
False               True               ...   
True                False              ...   

                                       IUD  cause birth defects._Disagree  \
your  gender_Female your  gender_Male                                       
False               True                                               49   
True                False                                              91   

                                       IUD Do not cause cancer._Disagree  \
your  gender_Female your  gender_Male                                      
False               True                                              43   
True                False                                             79   

                                       IUD Do not move to the heart or brain_Disagree  \
your  gender_Female your  gender_Male                                                   
False               True                                                           32   
True                False                                                          78   

                                       IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
your  gender_Female your  gender_Male                                                                               
False               True                                                              45                            
True                False                                                             75                            

                                       IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
your  gender_Female your  gender_Male                                                                  
False               True                                                              56               
True                False                                                             83               

                                       A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
your  gender_Female your  gender_Male                                                                                                                                                                                                     
False               True                                                              38                                                                                                                                                  
True                False                                                             79                                                                                                                                                  

                                       WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
your  gender_Female your  gender_Male                                                                                                                                                                            
False               True                                                               9                                                                                                                         
True                False                                                             26                                                                                                                         

                                       A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
your  gender_Female your  gender_Male                                                                                                                                                               
False               True                                                              63                                                                                                            
True                False                                                            124                                                                                                            

                                       A woman has acne while using an IUD. What is your advice?_all of above  \
your  gender_Female your  gender_Male                                                                           
False               True                                                              16                        
True                False                                                             51                        

                                       For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
your  gender_Female your  gender_Male                                                                                                                                       
False               True                                                              12                                                                                    
True                False                                                             34                                                                                    

[2 rows x 25 columns]
In [32]:
new_df = pd.DataFrame()
# Assign columns from df1 to new_df 'result',  'Your age ','your years of experience'
new_df['your  gender'] = df['your  gender']
new_df['what is your information source/s about IUD ?'] = df['what is your information source/s about IUD ?']
new_df['your monthly income '] = df['your monthly income ']
new_df['result']=df['result']

# Assign columns from df2 to new_df
for column in selected_df.columns:
    new_df[column] = selected_df[column]

# Print the new DataFrame
print(new_df)
    your  gender what is your information source/s about IUD ?  \
1         Female                         My university studies   
3         Female                         My university studies   
8         Female                         My university studies   
12        Female        My university studies, Self experience   
18        Female                               Self experience   
..           ...                                           ...   
357         Male                               Self experience   
358         Male                                      Research   
359         Male                     Self experience, Research   
360         Male                               Self experience   
361         Male                                      Research   

     your monthly income   result  Your age   your years of experience  \
1                     0.0      21       25.0                       1.0   
3                   222.0      18       24.0                      22.0   
8                   500.0      18       33.0                       9.0   
12                  250.0      21       26.0                       2.0   
18                  450.0      15       27.0                       3.0   
..                    ...     ...        ...                       ...   
357                 365.0       5       38.0                      16.0   
358                 385.0       6       53.0                      27.0   
359                 415.0      11       37.0                      15.0   
360                 355.0       9       41.0                      18.0   
361                 470.0      11       50.0                      28.0   

     Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
1                                                 True                                                                                                                                          
3                                                False                                                                                                                                          
8                                                False                                                                                                                                          
12                                               False                                                                                                                                          
18                                               False                                                                                                                                          
..                                                 ...                                                                                                                                          
357                                              False                                                                                                                                          
358                                              False                                                                                                                                          
359                                              False                                                                                                                                          
360                                              False                                                                                                                                          
361                                               True                                                                                                                                          

     women cant use a copper IUD if she  _all of above  \
1                                                 True   
3                                                 True   
8                                                False   
12                                                True   
18                                                True   
..                                                 ...   
357                                              False   
358                                              False   
359                                              False   
360                                              False   
361                                              False   

     one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
1                                                 True                                                                                         
3                                                False                                                                                         
8                                                False                                                                                         
12                                               False                                                                                         
18                                               False                                                                                         
..                                                 ...                                                                                         
357                                              False                                                                                         
358                                              False                                                                                         
359                                               True                                                                                         
360                                              False                                                                                         
361                                              False                                                                                         

     An IUD can be inserted  _during the period or at the day after your period finish  \
1                                                False                                   
3                                                False                                   
8                                                 True                                   
12                                                True                                   
18                                               False                                   
..                                                 ...                                   
357                                              False                                   
358                                              False                                   
359                                              False                                   
360                                              False                                   
361                                               True                                   

     ...  IUD  cause birth defects._Disagree  \
1    ...                                True   
3    ...                                True   
8    ...                                True   
12   ...                                True   
18   ...                               False   
..   ...                                 ...   
357  ...                               False   
358  ...                                True   
359  ...                               False   
360  ...                               False   
361  ...                               False   

     IUD Do not cause cancer._Disagree  \
1                                False   
3                                 True   
8                                False   
12                                True   
18                               False   
..                                 ...   
357                               True   
358                               True   
359                              False   
360                               True   
361                               True   

     IUD Do not move to the heart or brain_Disagree  \
1                                             False   
3                                             False   
8                                             False   
12                                            False   
18                                             True   
..                                              ...   
357                                           False   
358                                           False   
359                                           False   
360                                           False   
361                                            True   

     IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
1                                                False                            
3                                                False                            
8                                                False                            
12                                               False                            
18                                               False                            
..                                                 ...                            
357                                               True                            
358                                              False                            
359                                               True                            
360                                               True                            
361                                               True                            

     IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
1                                                 True               
3                                                False               
8                                                False               
12                                                True               
18                                               False               
..                                                 ...               
357                                              False               
358                                              False               
359                                               True               
360                                               True               
361                                               True               

     A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
1                                                 True                                                                                                                                                  
3                                                False                                                                                                                                                  
8                                                False                                                                                                                                                  
12                                                True                                                                                                                                                  
18                                               False                                                                                                                                                  
..                                                 ...                                                                                                                                                  
357                                              False                                                                                                                                                  
358                                              False                                                                                                                                                  
359                                              False                                                                                                                                                  
360                                              False                                                                                                                                                  
361                                               True                                                                                                                                                  

     WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
1                                                 True                                                                                                                         
3                                                False                                                                                                                         
8                                                False                                                                                                                         
12                                                True                                                                                                                         
18                                               False                                                                                                                         
..                                                 ...                                                                                                                         
357                                              False                                                                                                                         
358                                              False                                                                                                                         
359                                               True                                                                                                                         
360                                              False                                                                                                                         
361                                              False                                                                                                                         

     A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
1                                                False                                                                                                            
3                                                False                                                                                                            
8                                                 True                                                                                                            
12                                               False                                                                                                            
18                                               False                                                                                                            
..                                                 ...                                                                                                            
357                                              False                                                                                                            
358                                              False                                                                                                            
359                                              False                                                                                                            
360                                               True                                                                                                            
361                                               True                                                                                                            

     A woman has acne while using an IUD. What is your advice?_all of above  \
1                                                False                        
3                                                False                        
8                                                False                        
12                                               False                        
18                                               False                        
..                                                 ...                        
357                                              False                        
358                                              False                        
359                                               True                        
360                                              False                        
361                                              False                        

     For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
1                                                False                                                                                    
3                                                False                                                                                    
8                                                False                                                                                    
12                                                True                                                                                    
18                                               False                                                                                    
..                                                 ...                                                                                    
357                                              False                                                                                    
358                                              False                                                                                    
359                                               True                                                                                    
360                                              False                                                                                    
361                                              False                                                                                    

[315 rows x 28 columns]
In [33]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('what is your information source/s about IUD ?')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

# Specify the file path where you want to save the Excel file
#excel_file_path = "sourceOF_data.xlsx"

# Write the grouped DataFrame to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                                                  result  Your age   \
what is your information source/s about IUD ?                         
My university studies                                349     1355.0   
My university studies, Research                      363     1511.0   
My university studies, Self experience               327     1258.0   
My university studies, Self experience, Research     187      539.0   
Research                                             278     1129.0   
Self experience                                      455     1828.0   
Self experience, Research                            662     2917.0   

                                                  your years of experience  \
what is your information source/s about IUD ?                                
My university studies                                                446.0   
My university studies, Research                                      404.0   
My university studies, Self experience                               371.5   
My university studies, Self experience, Research                     190.0   
Research                                                             339.6   
Self experience                                                      585.0   
Self experience, Research                                            957.0   

                                                  Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
what is your information source/s about IUD ?                                                                                                                                                                                                
My university studies                                                                            13                                                                                                                                          
My university studies, Research                                                                  17                                                                                                                                          
My university studies, Self experience                                                           12                                                                                                                                          
My university studies, Self experience, Research                                                 10                                                                                                                                          
Research                                                                                         15                                                                                                                                          
Self experience                                                                                  18                                                                                                                                          
Self experience, Research                                                                        32                                                                                                                                          

                                                  women cant use a copper IUD if she  _all of above  \
what is your information source/s about IUD ?                                                         
My university studies                                                                             8   
My university studies, Research                                                                   4   
My university studies, Self experience                                                           10   
My university studies, Self experience, Research                                                  9   
Research                                                                                         12   
Self experience                                                                                  11   
Self experience, Research                                                                         7   

                                                  one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
what is your information source/s about IUD ?                                                                                                                                               
My university studies                                                                             6                                                                                         
My university studies, Research                                                                  11                                                                                         
My university studies, Self experience                                                           12                                                                                         
My university studies, Self experience, Research                                                  4                                                                                         
Research                                                                                          5                                                                                         
Self experience                                                                                  10                                                                                         
Self experience, Research                                                                        14                                                                                         

                                                  An IUD can be inserted  _during the period or at the day after your period finish  \
what is your information source/s about IUD ?                                                                                         
My university studies                                                                            14                                   
My university studies, Research                                                                  16                                   
My university studies, Self experience                                                           12                                   
My university studies, Self experience, Research                                                  8                                   
Research                                                                                          7                                   
Self experience                                                                                  19                                   
Self experience, Research                                                                        22                                   

                                                  both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
what is your information source/s about IUD ?                                                                             
My university studies                                                                            27                       
My university studies, Research                                                                  33                       
My university studies, Self experience                                                           25                       
My university studies, Self experience, Research                                                 14                       
Research                                                                                         18                       
Self experience                                                                                  38                       
Self experience, Research                                                                        59                       

                                                  We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
what is your information source/s about IUD ?                                                                                                                      
My university studies                                                                            22                                                                
My university studies, Research                                                                  36                                                                
My university studies, Self experience                                                           31                                                                
My university studies, Self experience, Research                                                 13                                                                
Research                                                                                         23                                                                
Self experience                                                                                  37                                                                
Self experience, Research                                                                        66                                                                

                                                  IUD Can be used by women of any age, including adolescents._Agree  \
what is your information source/s about IUD ?                                                                         
My university studies                                                                            12                   
My university studies, Research                                                                  14                   
My university studies, Self experience                                                           10                   
My university studies, Self experience, Research                                                  8                   
Research                                                                                          5                   
Self experience                                                                                  10                   
Self experience, Research                                                                        11                   

                                                  ...  \
what is your information source/s about IUD ?     ...   
My university studies                             ...   
My university studies, Research                   ...   
My university studies, Self experience            ...   
My university studies, Self experience, Research  ...   
Research                                          ...   
Self experience                                   ...   
Self experience, Research                         ...   

                                                  IUD  cause birth defects._Disagree  \
what is your information source/s about IUD ?                                          
My university studies                                                             20   
My university studies, Research                                                   20   
My university studies, Self experience                                            19   
My university studies, Self experience, Research                                  10   
Research                                                                          13   
Self experience                                                                   24   
Self experience, Research                                                         34   

                                                  IUD Do not cause cancer._Disagree  \
what is your information source/s about IUD ?                                         
My university studies                                                            13   
My university studies, Research                                                  23   
My university studies, Self experience                                           11   
My university studies, Self experience, Research                                  4   
Research                                                                         10   
Self experience                                                                  23   
Self experience, Research                                                        38   

                                                  IUD Do not move to the heart or brain_Disagree  \
what is your information source/s about IUD ?                                                      
My university studies                                                                         14   
My university studies, Research                                                               19   
My university studies, Self experience                                                         8   
My university studies, Self experience, Research                                               3   
Research                                                                                       9   
Self experience                                                                               22   
Self experience, Research                                                                     35   

                                                  IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
what is your information source/s about IUD ?                                                                                  
My university studies                                                                            14                            
My university studies, Research                                                                  16                            
My university studies, Self experience                                                           14                            
My university studies, Self experience, Research                                                  5                            
Research                                                                                         10                            
Self experience                                                                                  23                            
Self experience, Research                                                                        38                            

                                                  IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
what is your information source/s about IUD ?                                                                     
My university studies                                                                            21               
My university studies, Research                                                                  23               
My university studies, Self experience                                                           16               
My university studies, Self experience, Research                                                 11               
Research                                                                                         12               
Self experience                                                                                  21               
Self experience, Research                                                                        35               

                                                  A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
what is your information source/s about IUD ?                                                                                                                                                                                                        
My university studies                                                                            16                                                                                                                                                  
My university studies, Research                                                                  16                                                                                                                                                  
My university studies, Self experience                                                           14                                                                                                                                                  
My university studies, Self experience, Research                                                 10                                                                                                                                                  
Research                                                                                         11                                                                                                                                                  
Self experience                                                                                  23                                                                                                                                                  
Self experience, Research                                                                        27                                                                                                                                                  

                                                  WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
what is your information source/s about IUD ?                                                                                                                                                                               
My university studies                                                                             7                                                                                                                         
My university studies, Research                                                                   3                                                                                                                         
My university studies, Self experience                                                            6                                                                                                                         
My university studies, Self experience, Research                                                  4                                                                                                                         
Research                                                                                          5                                                                                                                         
Self experience                                                                                   4                                                                                                                         
Self experience, Research                                                                         6                                                                                                                         

                                                  A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
what is your information source/s about IUD ?                                                                                                                                                                  
My university studies                                                                            22                                                                                                            
My university studies, Research                                                                  29                                                                                                            
My university studies, Self experience                                                           22                                                                                                            
My university studies, Self experience, Research                                                  9                                                                                                            
Research                                                                                         16                                                                                                            
Self experience                                                                                  32                                                                                                            
Self experience, Research                                                                        57                                                                                                            

                                                  A woman has acne while using an IUD. What is your advice?_all of above  \
what is your information source/s about IUD ?                                                                              
My university studies                                                                             7                        
My university studies, Research                                                                   7                        
My university studies, Self experience                                                           10                        
My university studies, Self experience, Research                                                  6                        
Research                                                                                         11                        
Self experience                                                                                  11                        
Self experience, Research                                                                        15                        

                                                  For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
what is your information source/s about IUD ?                                                                                                                                          
My university studies                                                                             3                                                                                    
My university studies, Research                                                                   7                                                                                    
My university studies, Self experience                                                            4                                                                                    
My university studies, Self experience, Research                                                  6                                                                                    
Research                                                                                         15                                                                                    
Self experience                                                                                   5                                                                                    
Self experience, Research                                                                         6                                                                                    

[7 rows x 25 columns]
In [34]:
# Group by education level and calculate the percentage of True values for each boolean column
grouped_df_percentage = grouped_df.div(new_df.groupby('what is your information source/s about IUD ?').size(), axis=0) * 100

# Print the grouped DataFrame with percentages
print(grouped_df_percentage)
                                                       result    Your age   \
what is your information source/s about IUD ?                                
My university studies                              851.219512  3304.878049   
My university studies, Research                    772.340426  3214.893617   
My university studies, Self experience             860.526316  3310.526316   
My university studies, Self experience, Research  1100.000000  3170.588235   
Research                                           842.424242  3421.212121   
Self experience                                    858.490566  3449.056604   
Self experience, Research                          769.767442  3391.860465   

                                                  your years of experience  \
what is your information source/s about IUD ?                                
My university studies                                          1087.804878   
My university studies, Research                                 859.574468   
My university studies, Self experience                          977.631579   
My university studies, Self experience, Research               1117.647059   
Research                                                       1029.090909   
Self experience                                                1103.773585   
Self experience, Research                                      1112.790698   

                                                  Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
what is your information source/s about IUD ?                                                                                                                                                                                                
My university studies                                                                     31.707317                                                                                                                                          
My university studies, Research                                                           36.170213                                                                                                                                          
My university studies, Self experience                                                    31.578947                                                                                                                                          
My university studies, Self experience, Research                                          58.823529                                                                                                                                          
Research                                                                                  45.454545                                                                                                                                          
Self experience                                                                           33.962264                                                                                                                                          
Self experience, Research                                                                 37.209302                                                                                                                                          

                                                  women cant use a copper IUD if she  _all of above  \
what is your information source/s about IUD ?                                                         
My university studies                                                                     19.512195   
My university studies, Research                                                            8.510638   
My university studies, Self experience                                                    26.315789   
My university studies, Self experience, Research                                          52.941176   
Research                                                                                  36.363636   
Self experience                                                                           20.754717   
Self experience, Research                                                                  8.139535   

                                                  one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
what is your information source/s about IUD ?                                                                                                                                               
My university studies                                                                     14.634146                                                                                         
My university studies, Research                                                           23.404255                                                                                         
My university studies, Self experience                                                    31.578947                                                                                         
My university studies, Self experience, Research                                          23.529412                                                                                         
Research                                                                                  15.151515                                                                                         
Self experience                                                                           18.867925                                                                                         
Self experience, Research                                                                 16.279070                                                                                         

                                                  An IUD can be inserted  _during the period or at the day after your period finish  \
what is your information source/s about IUD ?                                                                                         
My university studies                                                                     34.146341                                   
My university studies, Research                                                           34.042553                                   
My university studies, Self experience                                                    31.578947                                   
My university studies, Self experience, Research                                          47.058824                                   
Research                                                                                  21.212121                                   
Self experience                                                                           35.849057                                   
Self experience, Research                                                                 25.581395                                   

                                                  both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
what is your information source/s about IUD ?                                                                             
My university studies                                                                     65.853659                       
My university studies, Research                                                           70.212766                       
My university studies, Self experience                                                    65.789474                       
My university studies, Self experience, Research                                          82.352941                       
Research                                                                                  54.545455                       
Self experience                                                                           71.698113                       
Self experience, Research                                                                 68.604651                       

                                                  We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
what is your information source/s about IUD ?                                                                                                                      
My university studies                                                                     53.658537                                                                
My university studies, Research                                                           76.595745                                                                
My university studies, Self experience                                                    81.578947                                                                
My university studies, Self experience, Research                                          76.470588                                                                
Research                                                                                  69.696970                                                                
Self experience                                                                           69.811321                                                                
Self experience, Research                                                                 76.744186                                                                

                                                  IUD Can be used by women of any age, including adolescents._Agree  \
what is your information source/s about IUD ?                                                                         
My university studies                                                                     29.268293                   
My university studies, Research                                                           29.787234                   
My university studies, Self experience                                                    26.315789                   
My university studies, Self experience, Research                                          47.058824                   
Research                                                                                  15.151515                   
Self experience                                                                           18.867925                   
Self experience, Research                                                                 12.790698                   

                                                  ...  \
what is your information source/s about IUD ?     ...   
My university studies                             ...   
My university studies, Research                   ...   
My university studies, Self experience            ...   
My university studies, Self experience, Research  ...   
Research                                          ...   
Self experience                                   ...   
Self experience, Research                         ...   

                                                  IUD  cause birth defects._Disagree  \
what is your information source/s about IUD ?                                          
My university studies                                                      48.780488   
My university studies, Research                                            42.553191   
My university studies, Self experience                                     50.000000   
My university studies, Self experience, Research                           58.823529   
Research                                                                   39.393939   
Self experience                                                            45.283019   
Self experience, Research                                                  39.534884   

                                                  IUD Do not cause cancer._Disagree  \
what is your information source/s about IUD ?                                         
My university studies                                                     31.707317   
My university studies, Research                                           48.936170   
My university studies, Self experience                                    28.947368   
My university studies, Self experience, Research                          23.529412   
Research                                                                  30.303030   
Self experience                                                           43.396226   
Self experience, Research                                                 44.186047   

                                                  IUD Do not move to the heart or brain_Disagree  \
what is your information source/s about IUD ?                                                      
My university studies                                                                  34.146341   
My university studies, Research                                                        40.425532   
My university studies, Self experience                                                 21.052632   
My university studies, Self experience, Research                                       17.647059   
Research                                                                               27.272727   
Self experience                                                                        41.509434   
Self experience, Research                                                              40.697674   

                                                  IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
what is your information source/s about IUD ?                                                                                  
My university studies                                                                     34.146341                            
My university studies, Research                                                           34.042553                            
My university studies, Self experience                                                    36.842105                            
My university studies, Self experience, Research                                          29.411765                            
Research                                                                                  30.303030                            
Self experience                                                                           43.396226                            
Self experience, Research                                                                 44.186047                            

                                                  IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
what is your information source/s about IUD ?                                                                     
My university studies                                                                     51.219512               
My university studies, Research                                                           48.936170               
My university studies, Self experience                                                    42.105263               
My university studies, Self experience, Research                                          64.705882               
Research                                                                                  36.363636               
Self experience                                                                           39.622642               
Self experience, Research                                                                 40.697674               

                                                  A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
what is your information source/s about IUD ?                                                                                                                                                                                                        
My university studies                                                                     39.024390                                                                                                                                                  
My university studies, Research                                                           34.042553                                                                                                                                                  
My university studies, Self experience                                                    36.842105                                                                                                                                                  
My university studies, Self experience, Research                                          58.823529                                                                                                                                                  
Research                                                                                  33.333333                                                                                                                                                  
Self experience                                                                           43.396226                                                                                                                                                  
Self experience, Research                                                                 31.395349                                                                                                                                                  

                                                  WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
what is your information source/s about IUD ?                                                                                                                                                                               
My university studies                                                                     17.073171                                                                                                                         
My university studies, Research                                                            6.382979                                                                                                                         
My university studies, Self experience                                                    15.789474                                                                                                                         
My university studies, Self experience, Research                                          23.529412                                                                                                                         
Research                                                                                  15.151515                                                                                                                         
Self experience                                                                            7.547170                                                                                                                         
Self experience, Research                                                                  6.976744                                                                                                                         

                                                  A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
what is your information source/s about IUD ?                                                                                                                                                                  
My university studies                                                                     53.658537                                                                                                            
My university studies, Research                                                           61.702128                                                                                                            
My university studies, Self experience                                                    57.894737                                                                                                            
My university studies, Self experience, Research                                          52.941176                                                                                                            
Research                                                                                  48.484848                                                                                                            
Self experience                                                                           60.377358                                                                                                            
Self experience, Research                                                                 66.279070                                                                                                            

                                                  A woman has acne while using an IUD. What is your advice?_all of above  \
what is your information source/s about IUD ?                                                                              
My university studies                                                                     17.073171                        
My university studies, Research                                                           14.893617                        
My university studies, Self experience                                                    26.315789                        
My university studies, Self experience, Research                                          35.294118                        
Research                                                                                  33.333333                        
Self experience                                                                           20.754717                        
Self experience, Research                                                                 17.441860                        

                                                  For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
what is your information source/s about IUD ?                                                                                                                                          
My university studies                                                                      7.317073                                                                                    
My university studies, Research                                                           14.893617                                                                                    
My university studies, Self experience                                                    10.526316                                                                                    
My university studies, Self experience, Research                                          35.294118                                                                                    
Research                                                                                  45.454545                                                                                    
Self experience                                                                            9.433962                                                                                    
Self experience, Research                                                                  6.976744                                                                                    

[7 rows x 25 columns]
In [35]:
# Create an empty dictionary to store the counts
boolean_counts = {}

# Iterate over each boolean column
for column in new_df.columns:
    # Calculate value counts for the column
    counts = new_df[column].value_counts()
    
    # Store the counts in the dictionary
    boolean_counts[column] = counts

# Print the counts
for column, counts in boolean_counts.items():
    print(f"Column: {column}")
    print(counts)
    print()
Column: your  gender
your  gender
Female    210
Male      105
Name: count, dtype: int64

Column: what is your information source/s about IUD ?
what is your information source/s about IUD ?
Self experience, Research                           86
Self experience                                     53
My university studies, Research                     47
My university studies                               41
My university studies, Self experience              38
Research                                            33
My university studies, Self experience, Research    17
Name: count, dtype: int64

Column: your monthly income 
your monthly income 
310.0    19
410.0    17
340.0    17
380.0    17
400.0    16
         ..
222.0     1
467.0     1
483.0     1
378.0     1
355.0     1
Name: count, Length: 82, dtype: int64

Column: result
result
7     50
9     49
8     38
6     37
5     27
10    27
11    19
4     16
3     10
12     9
13     6
14     5
18     4
2      4
21     4
17     3
16     2
20     2
19     2
15     1
Name: count, dtype: int64

Column: Your age 
Your age 
29.0    35
30.0    26
28.0    23
34.0    19
32.0    18
33.0    15
31.0    15
42.0    15
27.0    14
26.0    13
25.0    11
35.0    10
23.0    10
39.0     9
41.0     9
44.0     9
37.0     8
24.0     8
36.0     6
38.0     5
45.0     5
43.0     4
22.0     4
46.0     4
40.0     3
53.0     3
55.0     3
51.0     3
60.0     2
54.0     1
49.0     1
47.0     1
56.0     1
63.0     1
50.0     1
Name: count, dtype: int64

Column: your years of experience
your years of experience
6.0     35
12.0    29
4.0     23
8.0     22
5.0     19
7.0     18
9.0     17
1.0     16
3.0     16
11.0    13
19.0    11
13.0     9
2.0      8
14.0     8
18.0     8
16.0     8
17.0     7
15.0     6
10.0     6
26.0     5
20.0     5
22.0     5
24.0     3
28.0     2
23.0     2
30.0     2
27.0     2
25.0     2
21.0     2
45.0     1
11.5     1
40.0     1
0.6      1
43.0     1
31.0     1
Name: count, dtype: int64

Column: Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
False    198
True     117
Name: count, dtype: int64

Column: women cant use a copper IUD if she  _all of above
women cant use a copper IUD if she  _all of above
False    254
True      61
Name: count, dtype: int64

Column: one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
False    253
True      62
Name: count, dtype: int64

Column: An IUD can be inserted  _during the period or at the day after your period finish
An IUD can be inserted  _during the period or at the day after your period finish
False    217
True      98
Name: count, dtype: int64

Column: both hormonal and copper IUD are safe to use while breastfeeding._1.0
both hormonal and copper IUD are safe to use while breastfeeding._1.0
True     214
False    101
Name: count, dtype: int64

Column: We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
True     228
False     87
Name: count, dtype: int64

Column: IUD Can be used by women of any age, including adolescents._Agree
IUD Can be used by women of any age, including adolescents._Agree
False    245
True      70
Name: count, dtype: int64

Column: IUD Can not be used by women who have not had   children _Agree
IUD Can not be used by women who have not had   children _Agree
False    168
True     147
Name: count, dtype: int64

Column: IUD increase the risk of contracting STIs, including HIV
_Disagree
IUD increase the risk of contracting STIs, including HIV\n_Disagree
False    182
True     133
Name: count, dtype: int64

Column: IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree
IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree
False    170
True     145
Name: count, dtype: int64

Column: IUD make women infertile._Agree
IUD make women infertile._Agree
False    206
True     109
Name: count, dtype: int64

Column: IUD make women infertile._Disagree
IUD make women infertile._Disagree
False    170
True     145
Name: count, dtype: int64

Column: IUD  cause birth defects._Disagree
IUD  cause birth defects._Disagree
False    175
True     140
Name: count, dtype: int64

Column: IUD Do not cause cancer._Disagree
IUD Do not cause cancer._Disagree
False    193
True     122
Name: count, dtype: int64

Column: IUD Do not move to the heart or brain_Disagree
IUD Do not move to the heart or brain_Disagree
False    205
True     110
Name: count, dtype: int64

Column: IUD cause discomfort or pain for the woman or the man during sex._Disagree
IUD cause discomfort or pain for the woman or the man during sex._Disagree
False    195
True     120
Name: count, dtype: int64

Column: IUD Substantially reduce the risk of ectopic pregnancy._Agree
IUD Substantially reduce the risk of ectopic pregnancy._Agree
False    176
True     139
Name: count, dtype: int64

Column: A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
False    198
True     117
Name: count, dtype: int64

Column: WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
False    280
True      35
Name: count, dtype: int64

Column: A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
True     187
False    128
Name: count, dtype: int64

Column: A woman has acne while using an IUD. What is your advice?_all of above
A woman has acne while using an IUD. What is your advice?_all of above
False    248
True      67
Name: count, dtype: int64

Column: For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
False    269
True      46
Name: count, dtype: int64

In [36]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('your  gender')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

# Specify the file path where you want to save the Excel file
#excel_file_path = "genderC.xlsx"

# Write the grouped DataFrame to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
              result  Your age   your years of experience  \
your  gender                                                
Female          1740     6938.0                    2122.1   
Male             881     3599.0                    1171.0   

              Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
your  gender                                                                                                                                                                                             
Female                                                       69                                                                                                                                          
Male                                                         48                                                                                                                                          

              women cant use a copper IUD if she  _all of above  \
your  gender                                                      
Female                                                       46   
Male                                                         15   

              one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
your  gender                                                                                                                                            
Female                                                       39                                                                                         
Male                                                         23                                                                                         

              An IUD can be inserted  _during the period or at the day after your period finish  \
your  gender                                                                                      
Female                                                       60                                   
Male                                                         38                                   

              both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
your  gender                                                                          
Female                                                      139                       
Male                                                         75                       

              We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
your  gender                                                                                                                   
Female                                                      160                                                                
Male                                                         68                                                                

              IUD Can be used by women of any age, including adolescents._Agree  \
your  gender                                                                      
Female                                                       45                   
Male                                                         25                   

              ...  IUD  cause birth defects._Disagree  \
your  gender  ...                                       
Female        ...                                  91   
Male          ...                                  49   

              IUD Do not cause cancer._Disagree  \
your  gender                                      
Female                                       79   
Male                                         43   

              IUD Do not move to the heart or brain_Disagree  \
your  gender                                                   
Female                                                    78   
Male                                                      32   

              IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
your  gender                                                                               
Female                                                       75                            
Male                                                         45                            

              IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
your  gender                                                                  
Female                                                       83               
Male                                                         56               

              A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
your  gender                                                                                                                                                                                                     
Female                                                       79                                                                                                                                                  
Male                                                         38                                                                                                                                                  

              WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
your  gender                                                                                                                                                                            
Female                                                       26                                                                                                                         
Male                                                          9                                                                                                                         

              A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
your  gender                                                                                                                                                               
Female                                                      124                                                                                                            
Male                                                         63                                                                                                            

              A woman has acne while using an IUD. What is your advice?_all of above  \
your  gender                                                                           
Female                                                       51                        
Male                                                         16                        

              For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
your  gender                                                                                                                                       
Female                                                       34                                                                                    
Male                                                         12                                                                                    

[2 rows x 25 columns]
In [37]:
grouped_df = new_df.groupby('your  gender')[selected_columns].count()



# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('your  gender')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df_false)
#excel_file_path_false = "gender_false_data.xlsx"

# Write the grouped DataFrame to an Excel file
#grouped_df_false.to_excel(excel_file_path_false)

#print("Data has been written to", excel_file_path_false)
              result  Your age   your years of experience  \
your  gender                                                
Female         -1530    -6728.0                   -1912.1   
Male            -776    -3494.0                   -1066.0   

              Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
your  gender                                                                                                                                                                                             
Female                                                      141                                                                                                                                          
Male                                                         57                                                                                                                                          

              women cant use a copper IUD if she  _all of above  \
your  gender                                                      
Female                                                      164   
Male                                                         90   

              one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
your  gender                                                                                                                                            
Female                                                      171                                                                                         
Male                                                         82                                                                                         

              An IUD can be inserted  _during the period or at the day after your period finish  \
your  gender                                                                                      
Female                                                      150                                   
Male                                                         67                                   

              both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
your  gender                                                                          
Female                                                       71                       
Male                                                         30                       

              We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
your  gender                                                                                                                   
Female                                                       50                                                                
Male                                                         37                                                                

              IUD Can be used by women of any age, including adolescents._Agree  \
your  gender                                                                      
Female                                                      165                   
Male                                                         80                   

              ...  IUD  cause birth defects._Disagree  \
your  gender  ...                                       
Female        ...                                 119   
Male          ...                                  56   

              IUD Do not cause cancer._Disagree  \
your  gender                                      
Female                                      131   
Male                                         62   

              IUD Do not move to the heart or brain_Disagree  \
your  gender                                                   
Female                                                   132   
Male                                                      73   

              IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
your  gender                                                                               
Female                                                      135                            
Male                                                         60                            

              IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
your  gender                                                                  
Female                                                      127               
Male                                                         49               

              A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
your  gender                                                                                                                                                                                                     
Female                                                      131                                                                                                                                                  
Male                                                         67                                                                                                                                                  

              WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
your  gender                                                                                                                                                                            
Female                                                      184                                                                                                                         
Male                                                         96                                                                                                                         

              A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
your  gender                                                                                                                                                               
Female                                                       86                                                                                                            
Male                                                         42                                                                                                            

              A woman has acne while using an IUD. What is your advice?_all of above  \
your  gender                                                                           
Female                                                      159                        
Male                                                         89                        

              For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
your  gender                                                                                                                                       
Female                                                      176                                                                                    
Male                                                         93                                                                                    

[2 rows x 25 columns]
In [38]:
# Group by source of knowledge and calculate the count of each boolean column
grouped_df = new_df.groupby('what is your information source/s about IUD ?')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('what is your information source/s about IUD ?')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)

# Specify the file path where you want to save the Excel file
#excel_file_path = "source_false.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                                                  result  Your age   \
what is your information source/s about IUD ?                         
My university studies                               -308    -1314.0   
My university studies, Research                     -316    -1464.0   
My university studies, Self experience              -289    -1220.0   
My university studies, Self experience, Research    -170     -522.0   
Research                                            -245    -1096.0   
Self experience                                     -402    -1775.0   
Self experience, Research                           -576    -2831.0   

                                                  your years of experience  \
what is your information source/s about IUD ?                                
My university studies                                               -405.0   
My university studies, Research                                     -357.0   
My university studies, Self experience                              -333.5   
My university studies, Self experience, Research                    -173.0   
Research                                                            -306.6   
Self experience                                                     -532.0   
Self experience, Research                                           -871.0   

                                                  Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
what is your information source/s about IUD ?                                                                                                                                                                                                
My university studies                                                                            28                                                                                                                                          
My university studies, Research                                                                  30                                                                                                                                          
My university studies, Self experience                                                           26                                                                                                                                          
My university studies, Self experience, Research                                                  7                                                                                                                                          
Research                                                                                         18                                                                                                                                          
Self experience                                                                                  35                                                                                                                                          
Self experience, Research                                                                        54                                                                                                                                          

                                                  women cant use a copper IUD if she  _all of above  \
what is your information source/s about IUD ?                                                         
My university studies                                                                            33   
My university studies, Research                                                                  43   
My university studies, Self experience                                                           28   
My university studies, Self experience, Research                                                  8   
Research                                                                                         21   
Self experience                                                                                  42   
Self experience, Research                                                                        79   

                                                  one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
what is your information source/s about IUD ?                                                                                                                                               
My university studies                                                                            35                                                                                         
My university studies, Research                                                                  36                                                                                         
My university studies, Self experience                                                           26                                                                                         
My university studies, Self experience, Research                                                 13                                                                                         
Research                                                                                         28                                                                                         
Self experience                                                                                  43                                                                                         
Self experience, Research                                                                        72                                                                                         

                                                  An IUD can be inserted  _during the period or at the day after your period finish  \
what is your information source/s about IUD ?                                                                                         
My university studies                                                                            27                                   
My university studies, Research                                                                  31                                   
My university studies, Self experience                                                           26                                   
My university studies, Self experience, Research                                                  9                                   
Research                                                                                         26                                   
Self experience                                                                                  34                                   
Self experience, Research                                                                        64                                   

                                                  both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
what is your information source/s about IUD ?                                                                             
My university studies                                                                            14                       
My university studies, Research                                                                  14                       
My university studies, Self experience                                                           13                       
My university studies, Self experience, Research                                                  3                       
Research                                                                                         15                       
Self experience                                                                                  15                       
Self experience, Research                                                                        27                       

                                                  We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
what is your information source/s about IUD ?                                                                                                                      
My university studies                                                                            19                                                                
My university studies, Research                                                                  11                                                                
My university studies, Self experience                                                            7                                                                
My university studies, Self experience, Research                                                  4                                                                
Research                                                                                         10                                                                
Self experience                                                                                  16                                                                
Self experience, Research                                                                        20                                                                

                                                  IUD Can be used by women of any age, including adolescents._Agree  \
what is your information source/s about IUD ?                                                                         
My university studies                                                                            29                   
My university studies, Research                                                                  33                   
My university studies, Self experience                                                           28                   
My university studies, Self experience, Research                                                  9                   
Research                                                                                         28                   
Self experience                                                                                  43                   
Self experience, Research                                                                        75                   

                                                  ...  \
what is your information source/s about IUD ?     ...   
My university studies                             ...   
My university studies, Research                   ...   
My university studies, Self experience            ...   
My university studies, Self experience, Research  ...   
Research                                          ...   
Self experience                                   ...   
Self experience, Research                         ...   

                                                  IUD  cause birth defects._Disagree  \
what is your information source/s about IUD ?                                          
My university studies                                                             21   
My university studies, Research                                                   27   
My university studies, Self experience                                            19   
My university studies, Self experience, Research                                   7   
Research                                                                          20   
Self experience                                                                   29   
Self experience, Research                                                         52   

                                                  IUD Do not cause cancer._Disagree  \
what is your information source/s about IUD ?                                         
My university studies                                                            28   
My university studies, Research                                                  24   
My university studies, Self experience                                           27   
My university studies, Self experience, Research                                 13   
Research                                                                         23   
Self experience                                                                  30   
Self experience, Research                                                        48   

                                                  IUD Do not move to the heart or brain_Disagree  \
what is your information source/s about IUD ?                                                      
My university studies                                                                         27   
My university studies, Research                                                               28   
My university studies, Self experience                                                        30   
My university studies, Self experience, Research                                              14   
Research                                                                                      24   
Self experience                                                                               31   
Self experience, Research                                                                     51   

                                                  IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
what is your information source/s about IUD ?                                                                                  
My university studies                                                                            27                            
My university studies, Research                                                                  31                            
My university studies, Self experience                                                           24                            
My university studies, Self experience, Research                                                 12                            
Research                                                                                         23                            
Self experience                                                                                  30                            
Self experience, Research                                                                        48                            

                                                  IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
what is your information source/s about IUD ?                                                                     
My university studies                                                                            20               
My university studies, Research                                                                  24               
My university studies, Self experience                                                           22               
My university studies, Self experience, Research                                                  6               
Research                                                                                         21               
Self experience                                                                                  32               
Self experience, Research                                                                        51               

                                                  A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
what is your information source/s about IUD ?                                                                                                                                                                                                        
My university studies                                                                            25                                                                                                                                                  
My university studies, Research                                                                  31                                                                                                                                                  
My university studies, Self experience                                                           24                                                                                                                                                  
My university studies, Self experience, Research                                                  7                                                                                                                                                  
Research                                                                                         22                                                                                                                                                  
Self experience                                                                                  30                                                                                                                                                  
Self experience, Research                                                                        59                                                                                                                                                  

                                                  WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
what is your information source/s about IUD ?                                                                                                                                                                               
My university studies                                                                            34                                                                                                                         
My university studies, Research                                                                  44                                                                                                                         
My university studies, Self experience                                                           32                                                                                                                         
My university studies, Self experience, Research                                                 13                                                                                                                         
Research                                                                                         28                                                                                                                         
Self experience                                                                                  49                                                                                                                         
Self experience, Research                                                                        80                                                                                                                         

                                                  A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
what is your information source/s about IUD ?                                                                                                                                                                  
My university studies                                                                            19                                                                                                            
My university studies, Research                                                                  18                                                                                                            
My university studies, Self experience                                                           16                                                                                                            
My university studies, Self experience, Research                                                  8                                                                                                            
Research                                                                                         17                                                                                                            
Self experience                                                                                  21                                                                                                            
Self experience, Research                                                                        29                                                                                                            

                                                  A woman has acne while using an IUD. What is your advice?_all of above  \
what is your information source/s about IUD ?                                                                              
My university studies                                                                            34                        
My university studies, Research                                                                  40                        
My university studies, Self experience                                                           28                        
My university studies, Self experience, Research                                                 11                        
Research                                                                                         22                        
Self experience                                                                                  42                        
Self experience, Research                                                                        71                        

                                                  For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
what is your information source/s about IUD ?                                                                                                                                          
My university studies                                                                            38                                                                                    
My university studies, Research                                                                  40                                                                                    
My university studies, Self experience                                                           34                                                                                    
My university studies, Self experience, Research                                                 11                                                                                    
Research                                                                                         18                                                                                    
Self experience                                                                                  48                                                                                    
Self experience, Research                                                                        80                                                                                    

[7 rows x 25 columns]
In [39]:
# Define the bins for age categories
bins = [21, 34, 44, float('inf')]  # Define the bin edges

# Define labels for the age categories
labels = ['22-34', '35-44', '45+']

# Use pd.cut() to create a new column 'Age Group' by categorizing the 'Your Age' column
new_df['Age Group'] = pd.cut(new_df['Your age '], bins=bins, labels=labels, right=False)

# Print the DataFrame with the new 'Age Group' column
print(new_df[['Your age ', 'Age Group']])
     Your age  Age Group
1         25.0     22-34
3         24.0     22-34
8         33.0     22-34
12        26.0     22-34
18        27.0     22-34
..         ...       ...
357       38.0     35-44
358       53.0       45+
359       37.0     35-44
360       41.0     35-44
361       50.0       45+

[315 rows x 2 columns]
In [40]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Age Group')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

excel_file_path = "age_CorrValu.xlsx"

# Write the grouped DataFrame for false values to an Excel file
grouped_df.to_excel(excel_file_path)

print("Data has been written to", excel_file_path)
           result  Your age   your years of experience  \
Age Group                                                
22-34        1641     5476.0                    1214.6   
35-44         710     3340.0                    1256.5   
45+           270     1721.0                     822.0   

           Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
Age Group                                                                                                                                                                                             
22-34                                                     70                                                                                                                                          
35-44                                                     35                                                                                                                                          
45+                                                       12                                                                                                                                          

           women cant use a copper IUD if she  _all of above  \
Age Group                                                      
22-34                                                     42   
35-44                                                     14   
45+                                                        5   

           one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
Age Group                                                                                                                                            
22-34                                                     42                                                                                         
35-44                                                     14                                                                                         
45+                                                        6                                                                                         

           An IUD can be inserted  _during the period or at the day after your period finish  \
Age Group                                                                                      
22-34                                                     57                                   
35-44                                                     32                                   
45+                                                        9                                   

           both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
Age Group                                                                          
22-34                                                    126                       
35-44                                                     61                       
45+                                                       27                       

           We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
Age Group                                                                                                                   
22-34                                                    146                                                                
35-44                                                     56                                                                
45+                                                       26                                                                

           IUD Can be used by women of any age, including adolescents._Agree  \
Age Group                                                                      
22-34                                                     44                   
35-44                                                     18                   
45+                                                        8                   

           ...  IUD  cause birth defects._Disagree  \
Age Group  ...                                       
22-34      ...                                  89   
35-44      ...                                  37   
45+        ...                                  14   

           IUD Do not cause cancer._Disagree  \
Age Group                                      
22-34                                     66   
35-44                                     39   
45+                                       17   

           IUD Do not move to the heart or brain_Disagree  \
Age Group                                                   
22-34                                                  65   
35-44                                                  30   
45+                                                    15   

           IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
Age Group                                                                               
22-34                                                     69                            
35-44                                                     40                            
45+                                                       11                            

           IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
Age Group                                                                  
22-34                                                     83               
35-44                                                     39               
45+                                                       17               

           A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
Age Group                                                                                                                                                                                                     
22-34                                                     73                                                                                                                                                  
35-44                                                     30                                                                                                                                                  
45+                                                       14                                                                                                                                                  

           WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
Age Group                                                                                                                                                                            
22-34                                                     22                                                                                                                         
35-44                                                     11                                                                                                                         
45+                                                        2                                                                                                                         

           A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
Age Group                                                                                                                                                               
22-34                                                    112                                                                                                            
35-44                                                     54                                                                                                            
45+                                                       21                                                                                                            

           A woman has acne while using an IUD. What is your advice?_all of above  \
Age Group                                                                           
22-34                                                     44                        
35-44                                                     14                        
45+                                                        9                        

           For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
Age Group                                                                                                                                       
22-34                                                     31                                                                                    
35-44                                                     12                                                                                    
45+                                                        3                                                                                    

[3 rows x 25 columns]
Data has been written to age_CorrValu.xlsx
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\1958171519.py:2: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Age Group')[selected_columns].sum()
In [41]:
grouped_df = new_df.groupby('Age Group')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Age Group')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




excel_file_path = "age_wrongValu.xlsx"

# Write the grouped DataFrame for false values to an Excel file
grouped_df_false.to_excel(excel_file_path)

print("Data has been written to", excel_file_path)
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\2631165142.py:1: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Age Group')[selected_columns].count()
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\2631165142.py:4: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df_false = grouped_df - new_df.groupby('Age Group')[selected_columns].sum()
           result  Your age   your years of experience  \
Age Group                                                
22-34       -1449    -5284.0                   -1022.6   
35-44        -622    -3252.0                   -1168.5   
45+          -235    -1686.0                    -787.0   

           Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
Age Group                                                                                                                                                                                             
22-34                                                    122                                                                                                                                          
35-44                                                     53                                                                                                                                          
45+                                                       23                                                                                                                                          

           women cant use a copper IUD if she  _all of above  \
Age Group                                                      
22-34                                                    150   
35-44                                                     74   
45+                                                       30   

           one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
Age Group                                                                                                                                            
22-34                                                    150                                                                                         
35-44                                                     74                                                                                         
45+                                                       29                                                                                         

           An IUD can be inserted  _during the period or at the day after your period finish  \
Age Group                                                                                      
22-34                                                    135                                   
35-44                                                     56                                   
45+                                                       26                                   

           both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
Age Group                                                                          
22-34                                                     66                       
35-44                                                     27                       
45+                                                        8                       

           We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
Age Group                                                                                                                   
22-34                                                     46                                                                
35-44                                                     32                                                                
45+                                                        9                                                                

           IUD Can be used by women of any age, including adolescents._Agree  \
Age Group                                                                      
22-34                                                    148                   
35-44                                                     70                   
45+                                                       27                   

           ...  IUD  cause birth defects._Disagree  \
Age Group  ...                                       
22-34      ...                                 103   
35-44      ...                                  51   
45+        ...                                  21   

           IUD Do not cause cancer._Disagree  \
Age Group                                      
22-34                                    126   
35-44                                     49   
45+                                       18   

           IUD Do not move to the heart or brain_Disagree  \
Age Group                                                   
22-34                                                 127   
35-44                                                  58   
45+                                                    20   

           IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
Age Group                                                                               
22-34                                                    123                            
35-44                                                     48                            
45+                                                       24                            

           IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
Age Group                                                                  
22-34                                                    109               
35-44                                                     49               
45+                                                       18               

           A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
Age Group                                                                                                                                                                                                     
22-34                                                    119                                                                                                                                                  
35-44                                                     58                                                                                                                                                  
45+                                                       21                                                                                                                                                  

           WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
Age Group                                                                                                                                                                            
22-34                                                    170                                                                                                                         
35-44                                                     77                                                                                                                         
45+                                                       33                                                                                                                         

           A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
Age Group                                                                                                                                                               
22-34                                                     80                                                                                                            
35-44                                                     34                                                                                                            
45+                                                       14                                                                                                            

           A woman has acne while using an IUD. What is your advice?_all of above  \
Age Group                                                                           
22-34                                                    148                        
35-44                                                     74                        
45+                                                       26                        

           For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
Age Group                                                                                                                                       
22-34                                                    161                                                                                    
35-44                                                     76                                                                                    
45+                                                       32                                                                                    

[3 rows x 25 columns]
Data has been written to age_wrongValu.xlsx
In [42]:
# Define the bins for the categories
bins = [-1, 10, 20, float('inf')]  # -1 is for 0, float('inf') is for 20+

# Define the labels for the categories
labels = ['0-10', '11-20', '20+']

# Create a new column with the categorized year of experience
new_df['Experience Category'] = pd.cut(new_df['your years of experience'], bins=bins, labels=labels, right=False)

# Display the DataFrame with the new column
print(new_df[['your years of experience', 'Experience Category']])
     your years of experience Experience Category
1                         1.0                0-10
3                        22.0                 20+
8                         9.0                0-10
12                        2.0                0-10
18                        3.0                0-10
..                        ...                 ...
357                      16.0               11-20
358                      27.0                 20+
359                      15.0               11-20
360                      18.0               11-20
361                      28.0                 20+

[315 rows x 2 columns]
In [43]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Experience Category')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

#excel_file_path = "Experience_C.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\3879462704.py:2: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Experience Category')[selected_columns].sum()
                     result  Your age   your years of experience  \
Experience Category                                                
0-10                   1476     4974.0                     932.6   
11-20                   831     3974.0                    1481.5   
20+                     314     1589.0                     879.0   

                     Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
Experience Category                                                                                                                                                                                             
0-10                                                                62                                                                                                                                          
11-20                                                               41                                                                                                                                          
20+                                                                 14                                                                                                                                          

                     women cant use a copper IUD if she  _all of above  \
Experience Category                                                      
0-10                                                                36   
11-20                                                               17   
20+                                                                  8   

                     one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
Experience Category                                                                                                                                            
0-10                                                                35                                                                                         
11-20                                                               21                                                                                         
20+                                                                  6                                                                                         

                     An IUD can be inserted  _during the period or at the day after your period finish  \
Experience Category                                                                                      
0-10                                                                56                                   
11-20                                                               33                                   
20+                                                                  9                                   

                     both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
Experience Category                                                                          
0-10                                                               116                       
11-20                                                               70                       
20+                                                                 28                       

                     We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
Experience Category                                                                                                                   
0-10                                                               132                                                                
11-20                                                               71                                                                
20+                                                                 25                                                                

                     IUD Can be used by women of any age, including adolescents._Agree  \
Experience Category                                                                      
0-10                                                                40                   
11-20                                                               23                   
20+                                                                  7                   

                     ...  IUD  cause birth defects._Disagree  \
Experience Category  ...                                       
0-10                 ...                                  83   
11-20                ...                                  39   
20+                  ...                                  18   

                     IUD Do not cause cancer._Disagree  \
Experience Category                                      
0-10                                                64   
11-20                                               39   
20+                                                 19   

                     IUD Do not move to the heart or brain_Disagree  \
Experience Category                                                   
0-10                                                             60   
11-20                                                            34   
20+                                                              16   

                     IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
Experience Category                                                                               
0-10                                                                60                            
11-20                                                               44                            
20+                                                                 16                            

                     IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
Experience Category                                                                  
0-10                                                                76               
11-20                                                               45               
20+                                                                 18               

                     A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
Experience Category                                                                                                                                                                                                     
0-10                                                                67                                                                                                                                                  
11-20                                                               33                                                                                                                                                  
20+                                                                 17                                                                                                                                                  

                     WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
Experience Category                                                                                                                                                                            
0-10                                                                19                                                                                                                         
11-20                                                               14                                                                                                                         
20+                                                                  2                                                                                                                         

                     A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
Experience Category                                                                                                                                                               
0-10                                                               104                                                                                                            
11-20                                                               59                                                                                                            
20+                                                                 24                                                                                                            

                     A woman has acne while using an IUD. What is your advice?_all of above  \
Experience Category                                                                           
0-10                                                                41                        
11-20                                                               19                        
20+                                                                  7                        

                     For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
Experience Category                                                                                                                                       
0-10                                                                25                                                                                    
11-20                                                               18                                                                                    
20+                                                                  3                                                                                    

[3 rows x 25 columns]
In [44]:
grouped_df = new_df.groupby('Experience Category')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Experience Category')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




#excel_file_path = "Experience_w.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
                     result  Your age   your years of experience  \
Experience Category                                                
0-10                  -1301    -4799.0                    -757.6   
11-20                  -725    -3868.0                   -1375.5   
20+                    -280    -1555.0                    -845.0   

                     Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding  \
Experience Category                                                                                                                                                                                             
0-10                                                               113                                                                                                                                          
11-20                                                               65                                                                                                                                          
20+                                                                 20                                                                                                                                          

                     women cant use a copper IUD if she  _all of above  \
Experience Category                                                      
0-10                                                               139   
11-20                                                               89   
20+                                                                 26   

                     one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.  \
Experience Category                                                                                                                                            
0-10                                                               140                                                                                         
11-20                                                               85                                                                                         
20+                                                                 28                                                                                         

                     An IUD can be inserted  _during the period or at the day after your period finish  \
Experience Category                                                                                      
0-10                                                               119                                   
11-20                                                               73                                   
20+                                                                 25                                   

                     both hormonal and copper IUD are safe to use while breastfeeding._1.0  \
Experience Category                                                                          
0-10                                                                59                       
11-20                                                               36                       
20+                                                                  6                       

                     We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0  \
Experience Category                                                                                                                   
0-10                                                                43                                                                
11-20                                                               35                                                                
20+                                                                  9                                                                

                     IUD Can be used by women of any age, including adolescents._Agree  \
Experience Category                                                                      
0-10                                                               135                   
11-20                                                               83                   
20+                                                                 27                   

                     ...  IUD  cause birth defects._Disagree  \
Experience Category  ...                                       
0-10                 ...                                  92   
11-20                ...                                  67   
20+                  ...                                  16   

                     IUD Do not cause cancer._Disagree  \
Experience Category                                      
0-10                                               111   
11-20                                               67   
20+                                                 15   

                     IUD Do not move to the heart or brain_Disagree  \
Experience Category                                                   
0-10                                                            115   
11-20                                                            72   
20+                                                              18   

                     IUD cause discomfort or pain for the woman or the man during sex._Disagree  \
Experience Category                                                                               
0-10                                                               115                            
11-20                                                               62                            
20+                                                                 18                            

                     IUD Substantially reduce the risk of ectopic pregnancy._Agree  \
Experience Category                                                                  
0-10                                                                99               
11-20                                                               61               
20+                                                                 16               

                     A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.  \
Experience Category                                                                                                                                                                                                     
0-10                                                               108                                                                                                                                                  
11-20                                                               73                                                                                                                                                  
20+                                                                 17                                                                                                                                                  

                     WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above  \
Experience Category                                                                                                                                                                            
0-10                                                               156                                                                                                                         
11-20                                                               92                                                                                                                         
20+                                                                 32                                                                                                                         

                     A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition  \
Experience Category                                                                                                                                                               
0-10                                                                71                                                                                                            
11-20                                                               47                                                                                                            
20+                                                                 10                                                                                                            

                     A woman has acne while using an IUD. What is your advice?_all of above  \
Experience Category                                                                           
0-10                                                               134                        
11-20                                                               87                        
20+                                                                 27                        

                     For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b  
Experience Category                                                                                                                                       
0-10                                                               150                                                                                    
11-20                                                               88                                                                                    
20+                                                                 31                                                                                    

[3 rows x 25 columns]
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\773932588.py:1: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df = new_df.groupby('Experience Category')[selected_columns].count()
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\773932588.py:4: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.
  grouped_df_false = grouped_df - new_df.groupby('Experience Category')[selected_columns].sum()
In [45]:
# Create an empty dictionary to store the counts
boolean_counts = {}

# Iterate over each boolean column
for column in new_df.columns:
    # Calculate value counts for the column
    counts = new_df[column].value_counts()
    
    # Store the counts in the dictionary
    boolean_counts[column] = counts

# Print the counts
for column, counts in boolean_counts.items():
    print(f"Column: {column}")
    print(counts)
    print()
Column: your  gender
your  gender
Female    210
Male      105
Name: count, dtype: int64

Column: what is your information source/s about IUD ?
what is your information source/s about IUD ?
Self experience, Research                           86
Self experience                                     53
My university studies, Research                     47
My university studies                               41
My university studies, Self experience              38
Research                                            33
My university studies, Self experience, Research    17
Name: count, dtype: int64

Column: your monthly income 
your monthly income 
310.0    19
410.0    17
340.0    17
380.0    17
400.0    16
         ..
222.0     1
467.0     1
483.0     1
378.0     1
355.0     1
Name: count, Length: 82, dtype: int64

Column: result
result
7     50
9     49
8     38
6     37
5     27
10    27
11    19
4     16
3     10
12     9
13     6
14     5
18     4
2      4
21     4
17     3
16     2
20     2
19     2
15     1
Name: count, dtype: int64

Column: Your age 
Your age 
29.0    35
30.0    26
28.0    23
34.0    19
32.0    18
33.0    15
31.0    15
42.0    15
27.0    14
26.0    13
25.0    11
35.0    10
23.0    10
39.0     9
41.0     9
44.0     9
37.0     8
24.0     8
36.0     6
38.0     5
45.0     5
43.0     4
22.0     4
46.0     4
40.0     3
53.0     3
55.0     3
51.0     3
60.0     2
54.0     1
49.0     1
47.0     1
56.0     1
63.0     1
50.0     1
Name: count, dtype: int64

Column: your years of experience
your years of experience
6.0     35
12.0    29
4.0     23
8.0     22
5.0     19
7.0     18
9.0     17
1.0     16
3.0     16
11.0    13
19.0    11
13.0     9
2.0      8
14.0     8
18.0     8
16.0     8
17.0     7
15.0     6
10.0     6
26.0     5
20.0     5
22.0     5
24.0     3
28.0     2
23.0     2
30.0     2
27.0     2
25.0     2
21.0     2
45.0     1
11.5     1
40.0     1
0.6      1
43.0     1
31.0     1
Name: count, dtype: int64

Column: Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding
False    198
True     117
Name: count, dtype: int64

Column: women cant use a copper IUD if she  _all of above
women cant use a copper IUD if she  _all of above
False    254
True      61
Name: count, dtype: int64

Column: one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.
False    253
True      62
Name: count, dtype: int64

Column: An IUD can be inserted  _during the period or at the day after your period finish
An IUD can be inserted  _during the period or at the day after your period finish
False    217
True      98
Name: count, dtype: int64

Column: both hormonal and copper IUD are safe to use while breastfeeding._1.0
both hormonal and copper IUD are safe to use while breastfeeding._1.0
True     214
False    101
Name: count, dtype: int64

Column: We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0
True     228
False     87
Name: count, dtype: int64

Column: IUD Can be used by women of any age, including adolescents._Agree
IUD Can be used by women of any age, including adolescents._Agree
False    245
True      70
Name: count, dtype: int64

Column: IUD Can not be used by women who have not had   children _Agree
IUD Can not be used by women who have not had   children _Agree
False    168
True     147
Name: count, dtype: int64

Column: IUD increase the risk of contracting STIs, including HIV
_Disagree
IUD increase the risk of contracting STIs, including HIV\n_Disagree
False    182
True     133
Name: count, dtype: int64

Column: IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree
IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree
False    170
True     145
Name: count, dtype: int64

Column: IUD make women infertile._Agree
IUD make women infertile._Agree
False    206
True     109
Name: count, dtype: int64

Column: IUD make women infertile._Disagree
IUD make women infertile._Disagree
False    170
True     145
Name: count, dtype: int64

Column: IUD  cause birth defects._Disagree
IUD  cause birth defects._Disagree
False    175
True     140
Name: count, dtype: int64

Column: IUD Do not cause cancer._Disagree
IUD Do not cause cancer._Disagree
False    193
True     122
Name: count, dtype: int64

Column: IUD Do not move to the heart or brain_Disagree
IUD Do not move to the heart or brain_Disagree
False    205
True     110
Name: count, dtype: int64

Column: IUD cause discomfort or pain for the woman or the man during sex._Disagree
IUD cause discomfort or pain for the woman or the man during sex._Disagree
False    195
True     120
Name: count, dtype: int64

Column: IUD Substantially reduce the risk of ectopic pregnancy._Agree
IUD Substantially reduce the risk of ectopic pregnancy._Agree
False    176
True     139
Name: count, dtype: int64

Column: A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.
False    198
True     117
Name: count, dtype: int64

Column: WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above
False    280
True      35
Name: count, dtype: int64

Column: A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition
True     187
False    128
Name: count, dtype: int64

Column: A woman has acne while using an IUD. What is your advice?_all of above
A woman has acne while using an IUD. What is your advice?_all of above
False    248
True      67
Name: count, dtype: int64

Column: For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b
False    269
True      46
Name: count, dtype: int64

Column: Age Group
Age Group
22-34    192
35-44     88
45+       35
Name: count, dtype: int64

Column: Experience Category
Experience Category
0-10     175
11-20    106
20+       34
Name: count, dtype: int64

In [46]:
# Iterate over each column and plot a pie chart
for column in new_df.columns:
    try:
        plt.figure()
        counts = df[column].value_counts()
        plt.pie(counts, labels=counts.index, autopct='%1.1f%%', startangle=140)
        plt.title(f'Proportion of Values for {column}')
        plt.axis('equal')
        plt.show()
    except Exception as e:
        print(f"Error plotting pie chart for column '{column}': {e}")
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
No description has been provided for this image
Error plotting pie chart for column 'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding': 'Which of the following is a benefit of implanting an intrauterine device (IUD), for which an IUD may be recommended, in addition to contraception?_Reduction of heavy menstrual bleeding'
Error plotting pie chart for column 'women cant use a copper IUD if she  _all of above': 'women cant use a copper IUD if she  _all of above'
Error plotting pie chart for column 'one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.': 'one of the following is consider as advantage of hormonal IUD _women can have irregular bleeding, lighter periods, or no period at all.'
Error plotting pie chart for column 'An IUD can be inserted  _during the period or at the day after your period finish': 'An IUD can be inserted  _during the period or at the day after your period finish'
Error plotting pie chart for column 'both hormonal and copper IUD are safe to use while breastfeeding._1.0': 'both hormonal and copper IUD are safe to use while breastfeeding._1.0'
Error plotting pie chart for column 'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0': 'We must advise the patient to take iron-containing supplements while using an IUD, especially a copper IUD_1.0'
Error plotting pie chart for column 'IUD Can be used by women of any age, including adolescents._Agree': 'IUD Can be used by women of any age, including adolescents._Agree'
Error plotting pie chart for column 'IUD Can not be used by women who have not had   children _Agree': 'IUD Can not be used by women who have not had   children _Agree'
Error plotting pie chart for column 'IUD increase the risk of contracting STIs, including HIV
_Disagree': 'IUD increase the risk of contracting STIs, including HIV\n_Disagree'
Error plotting pie chart for column 'IUD Do not increase the risk of miscarriage when a woman becomes pregnant
after the IUD is removed_Agree': 'IUD Do not increase the risk of miscarriage when a woman becomes pregnant\nafter the IUD is removed_Agree'
Error plotting pie chart for column 'IUD make women infertile._Agree': 'IUD make women infertile._Agree'
Error plotting pie chart for column 'IUD make women infertile._Disagree': 'IUD make women infertile._Disagree'
Error plotting pie chart for column 'IUD  cause birth defects._Disagree': 'IUD  cause birth defects._Disagree'
Error plotting pie chart for column 'IUD Do not cause cancer._Disagree': 'IUD Do not cause cancer._Disagree'
Error plotting pie chart for column 'IUD Do not move to the heart or brain_Disagree': 'IUD Do not move to the heart or brain_Disagree'
Error plotting pie chart for column 'IUD cause discomfort or pain for the woman or the man during sex._Disagree': 'IUD cause discomfort or pain for the woman or the man during sex._Disagree'
Error plotting pie chart for column 'IUD Substantially reduce the risk of ectopic pregnancy._Agree': 'IUD Substantially reduce the risk of ectopic pregnancy._Agree'
Error plotting pie chart for column 'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.': 'A woman has severe pain in her lower abdomen, unusual vaginal discharge, and a fever. What is your advice?_Consult a gynecologist to rule out pelvic inflammatory disease and ectopic pregnancy.'
Error plotting pie chart for column 'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above': 'WOMEN experience changes in her bleeding patterns. she have heavier or longer periods than she had before getting the copper IUD , what is your advice ?  _all of above'
Error plotting pie chart for column 'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition': 'A womans monthly bleeding stops very soon after the insertion of a hormonal IUD. What is your advice ?_assess for pregnancy or other underlying  condition'
Error plotting pie chart for column 'A woman has acne while using an IUD. What is your advice?_all of above': 'A woman has acne while using an IUD. What is your advice?_all of above'
Error plotting pie chart for column 'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b': 'For one or two days, PATEINT may have some minor cramps and light bleeding (spotting). WHAT ADVICE DO YOU HAVE FOR PATEINT?_a and b'
Error plotting pie chart for column 'Age Group': 'Age Group'
Error plotting pie chart for column 'Experience Category': 'Experience Category'
C:\Users\samir\AppData\Local\Temp\ipykernel_30804\3744677295.py:4: RuntimeWarning: More than 20 figures have been opened. Figures created through the pyplot interface (`matplotlib.pyplot.figure`) are retained until explicitly closed and may consume too much memory. (To control this warning, see the rcParam `figure.max_open_warning`). Consider using `matplotlib.pyplot.close()`.
  plt.figure()
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
<Figure size 640x480 with 0 Axes>
In [47]:
# Define the bins for the income categories
bins = [0, 400, 1000, float('inf')]  # Adjust the bin boundaries as needed

# Define the labels for the income categories
labels = ['Low Income 0-400', 'Medium Income 400-1000', 'High Income 1000+']

# Create a new column in your DataFrame that contains the income categories
new_df['Income Category'] = pd.cut(new_df['your monthly income '], bins=bins, labels=labels, right=False)

# Print the updated DataFrame to see the new column
print(new_df[['your monthly income ', 'Income Category']])

int(new_df)
     your monthly income          Income Category
1                     0.0        Low Income 0-400
3                   222.0        Low Income 0-400
8                   500.0  Medium Income 400-1000
12                  250.0        Low Income 0-400
18                  450.0  Medium Income 400-1000
..                    ...                     ...
357                 365.0        Low Income 0-400
358                 385.0        Low Income 0-400
359                 415.0  Medium Income 400-1000
360                 355.0        Low Income 0-400
361                 470.0  Medium Income 400-1000

[315 rows x 2 columns]
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[47], line 13
     10 # Print the updated DataFrame to see the new column
     11 print(new_df[['your monthly income ', 'Income Category']])
---> 13 int(new_df)

TypeError: int() argument must be a string, a bytes-like object or a real number, not 'DataFrame'
In [ ]:
grouped_df = new_df.groupby('Income Category')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Income Category')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




#excel_file_path = "Income_w.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
In [ ]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Income Category')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

#excel_file_path = "Income_C.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
In [ ]:
# Define the bins for grouping
bins = [0, 10, 22]  # Define the bin edges

# Define the labels for the groups
labels = ['result between 0-10', 'result between 11-21']

# Create a new column with the bin labels based on the final result column
new_df['Result Category'] = pd.cut(new_df['result'], bins=bins, labels=labels, right=False)

print(new_df[['result', 'Result Category']])
In [ ]:
# Group by education level and calculate the sum of True values for each boolean column
grouped_df = new_df.groupby('Result Category')[selected_columns].sum()

# Print the grouped DataFrame
print(grouped_df)

#excel_file_path = "result_C.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
In [ ]:
grouped_df = new_df.groupby('Result Category')[selected_columns].count()

# Subtract the sum of true values from the total count to get the sum of false values
grouped_df_false = grouped_df - new_df.groupby('Result Category')[selected_columns].sum()

# Print the grouped DataFrame for false values
print(grouped_df_false)




#excel_file_path = "result_w.xlsx"

# Write the grouped DataFrame for false values to an Excel file
#grouped_df_false.to_excel(excel_file_path)

#print("Data has been written to", excel_file_path)
In [ ]:
# Create an empty dictionary to store the counts
boolean_counts = {}

# Iterate over each boolean column
for column in new_df.columns:
    # Calculate value counts for the column
    counts = new_df[column].value_counts()
    
    # Store the counts in the dictionary
    boolean_counts[column] = counts

# Print the counts
for column, counts in boolean_counts.items():
    print(f"Column: {column}")
    print(counts)
    print()